Hi,
I'm trying to create a user form that searches through a sheet and displays results found. My first case is searching by name, and as some names appear more than once I'm trying to create a loop where every time a button is pressed then the next result is displayed and will loop back to the top of the sheet when it reaches the bottom.
This is the code I'e got so far, but at the moment there is a mismatch error occuring with found1 is false. Any pointers to what is wrong at the moment?
Code
Private Sub resultbtn_Click()
Dim ws As Worksheet
Dim Found1 As Boolean
Dim C As Range
Set ws = Worksheets("customers")
index = searchcb.ListIndex
Select Case index
Case Is = 0
If Found1 Is False Then
Set C = ws.Range("C:C").Find(searchtxt.Text, C, xlValues, xlWhole, xlByRows)
Found1 = True
Else
Set C = Columns(3).FindNext(C)
End If
If Not C Is Nothing Then
custnolbl.Caption = C.Offset(0, -2)
custnolbl.Caption = Format(custnolbl.Caption, "000#")
titlelbl.Caption = C.Offset(0, -1)
forenamelbl.Caption = C.Offset(0, 0)
surnamelbl.Caption = C.Offset(0, 1)
emaillbl.Caption = C.Offset(0, 2)
contactnolbl.Caption = C.Offset(0, 3)
contactnolbl.Caption = Format(contactnolbl.Caption, "0##########")
housenolbl.Caption = C.Offset(0, 4)
addresslbl.Caption = C.Offset(0, 5)
townlbl.Caption = C.Offset(0, 6)
postcodelbl.Caption = C.Offset(0, 7)
End If
Display More