I have a userform for search record in worksheet. The search code is below for refrence
The above code is written in change event of Textbox1, its works fine. Now I want to move next record from current record. so I simply write code below in cmdnext button. the code is
when i click the command button button it wouln't move to next record.
kindly help in this task.
Code:
Sub searchData()
If IsNumeric(UserForm1.TextBox1.Value) Then
flag = False
i = 0
Empid = UserForm1.TextBox1.Value
Do While cells(i + 1, 1).Value <> ""
If cells(i + 1, 1).Value = Empid Then
flag = True
For j = 2 To 34
UserForm1.Controls("TextBox" & j).Value = cells(i + 1, j).Value
Next j
End If
i = i + 1
Loop
If flag = False Then
For j = 2 To 34
UserForm1.Controls("TextBox" & j).Value = ""
Next j
End If
Else
ClearForm
End If
End Sub
The above code is written in change event of Textbox1, its works fine. Now I want to move next record from current record. so I simply write code below in cmdnext button. the code is
Code:
Private Sub cmdnext_Click()currentrow = i
currentrow = currentrow + 1
flag = True
For j = 1 To 34
UserForm1.Controls("TextBox" & j).Value = cells(currentrow, j).Value
Next j
End Sub
when i click the command button button it wouln't move to next record.
kindly help in this task.