İç İçe With Kullanımı - Baskı Önizleme +- AccessTr.neT (https://accesstr.net) +-- Forum: Microsoft Excel (https://accesstr.net/forum-microsoft-excel.html) +--- Forum: Excel Cevaplanmış Soruları (https://accesstr.net/forum-excel-cevaplanmis-sorulari.html) +--- Konu Başlığı: İç İçe With Kullanımı (/konu-ic-ice-with-kullanimi.html) |
İç İçe With Kullanımı - accessman - 14/01/2020 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 Cvp: İç İçe With Kullanımı - berduş - 14/01/2020 her . kendi withini alıyor galiba with s1 altındakiler doğrudan s1i alırken with s1 döngüsünün dışındakiler with s2 altında olduğunda s2yi alıyor sadece mantık yürütme dosyanızda değer vererek deneyebilirsiniz. Cvp: İç İçe With Kullanımı - accessman - 14/01/2020 teşekkürler Cvp: İç İçe With Kullanımı - feraz - 14/01/2020 En üstteki with s2 ile en alttaki end with bağlantılı. |