Skip to main content

AccessTr.neT


İç İçe With Kullanımı

İç İçe With Kullanımı

Çözüldü #1
bir arkadaşın eklediği güzel bir kodda içi içe iki adet with kullanılmış burada hangisi hangisine bağlı nasıl anlaşılıyor

Private Sub CommandButton1_Click()

Dim s1 As Worksheet: Set s1 = Sheets("Sayfa1")
Dim s2 As Worksheet: Set s2 = Sheets("sakla")

   
With s2
       
With s1
       
       
If .Range("A1").Value <> "" Then
           
If Me.TextBox1.Value <= WorksheetFunction.Max(.Range("A2:A" & Rows.Count)) Then
                MsgBox "Büyük olamaz"
, vbCritical, "Hata"
               
Me.TextBox1.SetFocus
               
Me.TextBox1.BackColor = vbRed
               
Exit Sub
           
End If
       
End If
              .Range
("A" & s1.Cells(Rows.Count, 1).End(3).Row + 1).Value = Me.TextBox1.Value
              .Range
("B" & s1.Cells(Rows.Count, 1).End(3).Row).Value = Me.TextBox2.Value
       
End With
            .Range
("A1").Value = Me.TextBox1.Value
           
Me.TextBox1.Value = .Range("A1").Value + 1
   
End With

   
Set s1 = Nothing: Set s2 = Nothing
End Sub


Private Sub UserForm_Initialize()

   
If Sheets("sakla").Range("A1").Value <> "" Then
       
Me.TextBox1.Value = Sheets("sakla").Range("A1").Value + 1
   
Else
     
Me.TextBox1.Value = 1
   
End If
   
End Sub
@benbendedeilem
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da

Bu Konudaki Yorumlar
İç İçe With Kullanımı - Yazar: accessman - 14/01/2020, 14:22
Cvp: İç İçe With Kullanımı - Yazar: berduş - 14/01/2020, 14:30
Cvp: İç İçe With Kullanımı - Yazar: accessman - 14/01/2020, 14:39
Cvp: İç İçe With Kullanımı - Yazar: feraz - 14/01/2020, 14:47
Task