Searching over multiple columns in excel vba

后端 未结 4 1858
广开言路
广开言路 2020-12-04 00:34

I am able to search a text in column A of my spreadsheet by using this

With WB.Sheets(\"MySheet\")
    Set FindRow = .Range(\"A:A\").Find(What:=\"ProjTemp1\"         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 01:05

    An alternative suggestion is to just loop through the table and use nested if-statements like this:

    Sub ReturnRowNumber()
        Dim i As Long, GetRow As Long
        For i = 2 To Sheets("MySheet").Cells(Rows.Count, 1).End(xlUp).Row
            'Criteria search
            If Sheets("MySheet").Cells(i, 1).Value = "ProjTemp1" Then
                If Sheets("MySheet").Cells(i, 2).Value = "ProjTemp2" Then
                    If Sheets("MySheet").Cells(i, 3).Value = "ProjTemp3" Then
                        'Returns row
                        GetRow = i
                    End If
                End If
            End If
        Next i
    End Sub
    

提交回复
热议问题