我可以使用此方法在电子表格的A列中搜索文本

With WB.Sheets("MySheet")
    Set FindRow = .Range("A:A").Find(What:="ProjTemp1", LookIn:=xlValues)
End With


之后,我可以通过执行FindRow.Row获取行号

然后如何获取Column A == "ProjTemp1" && Column B == "ProjTemp2" && Column C == "ProjTemp3"所在的行号

最佳答案

尝试使用Autofilter

Dim rng As Range
'disable autofilter in case it's already enabled'
WB.Sheets("MySheet").AutoFilterMode = False

With WB.Sheets("MySheet").Range("A1:C1")
    'set autofilter'
    .AutoFilter Field:=1, Criteria1:="=ProjTemp1"
    .AutoFilter Field:=2, Criteria1:="=ProjTemp2"
    .AutoFilter Field:=3, Criteria1:="=ProjTemp3"
End With

With WB.Sheets("MySheet")
    On Error Resume Next
    Set rng = .Range("A2:A" & .Rows.Count).Rows.SpecialCells(xlCellTypeVisible)
    On Error GoTo 0
End With
If Not rng Is Nothing Then
   MsgBox rng.Row ' returns first visible row number
End If

WB.Sheets("MySheet").AutoFilterMode = False 'disable autofilter'

08-07 04:57