search with multiple criteria

jams

New member
Joined
Jun 14, 2013
Messages
9
Reaction score
0
Points
0
Hi all,

I am trying to create a code where I can search using 2 criteria.

I got this code from a work sheet
Code:
Private Sub cmdFind_Click()
    Dim strFind, FirstAddress As String   'what to find
    Dim rSearch As Range  'range to search


    Set rSearch = Worksheets("refund").Range("F2", Range("F65536").End(xlUp))


    strFind = Me.TextBox1.Value    'what to look for


    Dim f As Integer
    With rSearch
        Set C = .Find(strFind, SearchOrder:=xlRows, LookIn:=xlValues)
        If Not C Is Nothing Then    'found it
            C.Select
            With Me    'load entry to form
                .TextBox2.Value = C.Offset(0, -5).Value
                .TextBox3.Value = C.Offset(0, -4).Value
                .TextBox4.Value = C.Offset(0, -3).Value
                .TextBox5.Value = C.Offset(0, -2).Value
                .TextBox6.Value = C.Offset(0, 3).Value
                .TextBox7.Value = C.Offset(0, 4).Value
                .TextBox8.Value = C.Offset(0, 5).Value
                .TextBox9.Value = C.Offset(0, 6).Value
                .TextBox10.Value = C.Offset(0, 10).Value
                f = 0
            End With
            FirstAddress = C.Address
            Do
                f = f + 1    'count number of matching records
                Set C = .FindNext(C)
            Loop While Not C Is Nothing And C.Address <> FirstAddress
            If f > 1 Then
                MsgBox "There are " & f & " instances of " & strFind
                Me.Height = 518
            End If
        Else: MsgBox strFind & " not listed"    'search failed
        End If
    End With
 End Sub

 It works quite well with one criteria which it is designed for. I need to search for the importer and year. At present it only searches for the importer[ATTACH]1640._xfImport[/ATTACH]  I have attached the file  thanks
 
Back
Top