Hi dears
i searched and i find this code for editing worksheet data by user form based on value that enter in a text box :
Code
Private Sub CommandButton2_Click()Dim Rng As Range, Dn As Range
With Sheets("liste_karkonan")
Set Rng = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
For Each Dn In Rng
If Dn.Value = Val(TextBox12.Value) Then
Dn.Next.Value = Me.txtLoc.Value
Dn.Next.Next.Value = Me.ComboBox1.Value
Dn.Next.Next.Next.Next.Next.Value = Val(TextBox10.Text)
Dn.Next.Next.Next.Next.Next.Next.Next.Value = Me.TextBox11.Value
Dn.Next.Next.Next.Next.Next.Next.Next.Next.Next.Value = Me.ComboBox2.Value
End If
Next Dn
End With
End Sub
Display More
as you see this code is retrieving data based on TextBox12 value in sheet1, and you can change them, but there is something verry annoying : for every textbox you want to add to userform you have to enter next.next.next in your code .... it made me crazy when i want to use 20 or more textboxes
is there a better way ?
p.s : ( i dont want to use Offset in my code )