Soru buton ile gizli sayfayı yazdırma ve if-else kullanımı

Katılım
17 Temmuz 2021
Mesajlar
3
Excel Vers. ve Dili
20019 türkçe
merhabalar, üstatlar çok özür dileyerek bir soru sormak istiyorum. aşağıda bir kod yazdım ama istediğim gibi çalışmadı. Yardımcı olabilir misiniz rica etsem.
İstediğim şey şu:
SÖZLEŞME sayfasında B4 hücresi, VAR ise SÖZLEŞME sayfası 2 KOPYA, başka bir şey ise SÖZLEŞME sayfası 2 kopya ve EK sayfası 1 KOPYA olarak yazdıracak. Yalnız EK sayfası gizli..
gizli olması sıkıntı çıkartıyor ve if-else yapısını da kullanamadım.

Private Sub CommandButton1_Click()
If Sheets("SÖZLEŞME.CELL(2, 4)") = "VAR" Then
Sheets("SÖZLEŞME").PrintOut Copies:=2
Else
Sheets("SÖZLEŞME").PrintOut Copies:=2
Sheets("EK").PrintOut Copies:=1
End Sub
 
Katılım
14 Kasım 2017
Mesajlar
618
Excel Vers. ve Dili
2010 Türkçe
Altın Üyelik Bitiş Tarihi
07-01-2024
Bu şekilde deneyin.
Kod:
Private Sub CommandButton1_Click()
If Sheets("SÖZLEŞME.CELL(2, 4)") = "VAR" Then
Sheets("SÖZLEŞME").PrintOut Copies:=2
Else
Sheets("SÖZLEŞME").PrintOut Copies:=2
Sheets("EK").Visible = True
Sheets("EK").PrintOut Copies:=1
Sheets("EK").Visible =False
End Sub
 
Katılım
14 Kasım 2017
Mesajlar
618
Excel Vers. ve Dili
2010 Türkçe
Altın Üyelik Bitiş Tarihi
07-01-2024
Düzeltme
If komutunda da yanlışlık fark ettim aşağıdaki gibi deneyin.

Kod:
Private Sub CommandButton1_Click()
If Sheets("SÖZLEŞME").Range("B4") = "VAR" Then
Sheets("SÖZLEŞME").PrintOut Copies:=2
Else
Sheets("SÖZLEŞME").PrintOut Copies:=2
Sheets("EK").Visible = True
Sheets("EK").PrintOut Copies:=1
Sheets("EK").Visible = False
End If
End Sub
 

veyselemre

Özel Üye
Katılım
9 Mart 2005
Mesajlar
3,593
Excel Vers. ve Dili
Pro Plus 2021
Kod:
Private Sub CommandButton1_Click()
    Sheets("SÖZLEŞME").PrintOut Copies:=2
    If Not Sheets("SÖZLEŞME").Cells(4, 2) = "VAR" Then
        Sheets("EK").Visible = True
        Sheets("EK").PrintOut Copies:=1
        Sheets("EK").Visible = False
    End If
End Sub
 
Katılım
17 Temmuz 2021
Mesajlar
3
Excel Vers. ve Dili
20019 türkçe
Düzeltme
If komutunda da yanlışlık fark ettim aşağıdaki gibi deneyin.

Kod:
Private Sub CommandButton1_Click()
If Sheets("SÖZLEŞME").Range("B4") = "VAR" Then
Sheets("SÖZLEŞME").PrintOut Copies:=2
Else
Sheets("SÖZLEŞME").PrintOut Copies:=2
Sheets("EK").Visible = True
Sheets("EK").PrintOut Copies:=1
Sheets("EK").Visible = False
End If
End Sub
çok teşekkür ederim üstat çalıştı. zihnine sağlık
 
Üst