Hey fellas,
I have a userform with everything working fine aprt from my Find_Next and previous command. What happens is that it keeps giving the same results while it should finding all data that matches by search criteria. If anyone could help me in this, I would really appreciate.
Private Sub CB_FIND_NEXT_Click()
Dim lastrow
Dim Action_Taken As String
lastrow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
Action_Taken = txtAction_Taken
For currentrow = 2 To lastrow
If Cells(currentrow, 11).Text = Action_Taken Then
txtDate_Rcvd.Text = Cells(currentrow, 1).Text
txtFormat_Rcvd.Text = Cells(currentrow, 2).Text
txtIn_Out.Text = Cells(currentrow, 3).Text
txtPhone_No.Text = Cells(currentrow, 4).Text
txtCaller.Text = Cells(currentrow, 5).Text
txtViolator.Text = Cells(currentrow, 6).Text
txtBP_No.Text = Cells(currentrow, 7).Text
txtTaxType.Text = Cells(currentrow, 8).Text
txtResponseSent.Text = Cells(currentrow, 9).Text
txtTypeofResponse.Text = Cells(currentrow, 10).Text
txtAction_Taken.Text = Cells(currentrow, 11).Text
txtLead_Number.Text = Cells(currentrow, 12).Text
txtNonPursefolder_DOCName.Text = Cells(currentrow, 13).Text
txtComments.Text = Cells(currentrow, 14).Text
End If
Next currentrow
txtAction_Taken.SetFocus
End Sub
Private Sub CB_FIND_PREVIOUS_Click()
Dim lastrow
Dim Action_Taken As String
lastrow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
Action_Taken = txtAction_Taken
For currentrow = lastrow To 2 Step -1
If Cells(currentrow, 11).Text = Action_Taken Then
txtDate_Rcvd.Text = Cells(currentrow, 1).Text
txtFormat_Rcvd.Text = Cells(currentrow, 2).Text
txtIn_Out.Text = Cells(currentrow, 3).Text
txtPhone_No.Text = Cells(currentrow, 4).Text
txtCaller.Text = Cells(currentrow, 5).Text
txtViolator.Text = Cells(currentrow, 6).Text
txtBP_No.Text = Cells(currentrow, 7).Text
txtTaxType.Text = Cells(currentrow, 8).Text
txtResponseSent.Text = Cells(currentrow, 9).Text
txtTypeofResponse.Text = Cells(currentrow, 10).Text
txtAction_Taken.Text = Cells(currentrow, 11).Text
txtLead_Number.Text = Cells(currentrow, 12).Text
txtNonPursefolder_DOCName.Text = Cells(currentrow, 13).Text
txtComments.Text = Cells(currentrow, 14).Text
End If
Next currentrow
txtAction_Taken.SetFocus
End Sub
I have a userform with everything working fine aprt from my Find_Next and previous command. What happens is that it keeps giving the same results while it should finding all data that matches by search criteria. If anyone could help me in this, I would really appreciate.
Private Sub CB_FIND_NEXT_Click()
Dim lastrow
Dim Action_Taken As String
lastrow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
Action_Taken = txtAction_Taken
For currentrow = 2 To lastrow
If Cells(currentrow, 11).Text = Action_Taken Then
txtDate_Rcvd.Text = Cells(currentrow, 1).Text
txtFormat_Rcvd.Text = Cells(currentrow, 2).Text
txtIn_Out.Text = Cells(currentrow, 3).Text
txtPhone_No.Text = Cells(currentrow, 4).Text
txtCaller.Text = Cells(currentrow, 5).Text
txtViolator.Text = Cells(currentrow, 6).Text
txtBP_No.Text = Cells(currentrow, 7).Text
txtTaxType.Text = Cells(currentrow, 8).Text
txtResponseSent.Text = Cells(currentrow, 9).Text
txtTypeofResponse.Text = Cells(currentrow, 10).Text
txtAction_Taken.Text = Cells(currentrow, 11).Text
txtLead_Number.Text = Cells(currentrow, 12).Text
txtNonPursefolder_DOCName.Text = Cells(currentrow, 13).Text
txtComments.Text = Cells(currentrow, 14).Text
End If
Next currentrow
txtAction_Taken.SetFocus
End Sub
Private Sub CB_FIND_PREVIOUS_Click()
Dim lastrow
Dim Action_Taken As String
lastrow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
Action_Taken = txtAction_Taken
For currentrow = lastrow To 2 Step -1
If Cells(currentrow, 11).Text = Action_Taken Then
txtDate_Rcvd.Text = Cells(currentrow, 1).Text
txtFormat_Rcvd.Text = Cells(currentrow, 2).Text
txtIn_Out.Text = Cells(currentrow, 3).Text
txtPhone_No.Text = Cells(currentrow, 4).Text
txtCaller.Text = Cells(currentrow, 5).Text
txtViolator.Text = Cells(currentrow, 6).Text
txtBP_No.Text = Cells(currentrow, 7).Text
txtTaxType.Text = Cells(currentrow, 8).Text
txtResponseSent.Text = Cells(currentrow, 9).Text
txtTypeofResponse.Text = Cells(currentrow, 10).Text
txtAction_Taken.Text = Cells(currentrow, 11).Text
txtLead_Number.Text = Cells(currentrow, 12).Text
txtNonPursefolder_DOCName.Text = Cells(currentrow, 13).Text
txtComments.Text = Cells(currentrow, 14).Text
End If
Next currentrow
txtAction_Taken.SetFocus
End Sub