HTML Code:
HTML Code:
try this instead![]()
Private Sub TextBox1_Change() Dim lRow As Long Dim ws As Worksheet Set ws = Worksheets("Sheet1") If Len(Me.TextBox1.Value) > 6 Then MsgBox "Error!" Me.TextBox1.Value = Left(Me.TextBox1.Value, 6) End If lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row If Len(Me.TextBox1.Value) < 6 Then Exit Sub End If With ws .Cells(lRow, 1).Value = Me.TextBox1.Text Me.TextBox1.Value = Left(Me.TextBox1.Value, 6) TextBox2.SetFocus End With End Sub Private Sub TextBox2_Change() Dim lRow As Long Dim ws As Worksheet Set ws = Worksheets("Sheet1") If Len(Me.TextBox2.Value) > 10 Then MsgBox "Error!" Me.TextBox2.Value = Left(Me.TextBox2.Value, 10) End If If Len(Me.TextBox2.Value) < 10 Then Exit Sub End If lRow = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row With ws .Cells(lRow, 2).Value = Me.TextBox2.Text Me.TextBox2.Value = Left(Me.TextBox2.Value, 10) TextBox1.SetFocus End With End Sub
If you are satisfied with the solution(s) provided, please mark your thread as Solved.
Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.
Hi, humdingaling.
Thanks for your help.
I was having the same error with your code but i made a little modifications
and i guess that now it's working, this how i end with the code.
HTML Code:
not a problem
i wasnt sure how exactly it was meant to be react but its good you know enough VBA to amend yourself![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks