在excel vba问题中find一行

我有一个Excel列表3列的电子表格。 Column 1, Column 2, Column 3 我想做一个查找标准,所以我可以找回行的位置。 这怎么可能?。

要find一个标准,我可以做…但不知道如何扩展,所以它find匹配例如值1,值2,值3的行。

 Columns("A").Find(value, Range(A:A), xlValues, xlWhole) 

您可以使用数组来保存范围,然后search数组以查找值。 一旦find值,它将输出已经find的行号。

 Option Explicit Sub matchCriteria() Dim arrValues() As Variant Dim lrow As Long, i As Long Dim valOne As String, valTwo As String, valThree As String valOne = "x" 'Update to reflect the values you want to find valTwo = "y" valThree = "z" lrow = Cells(Rows.Count, 1).End(xlUp).Row arrValues = Range("A1:C" & lrow) For i = 1 To UBound(arrValues, 1) If arrValues(i, 1) = valOne _ And arrValues(i, 2) = valTwo _ And arrValues(i, 3) = valThree Then MsgBox ("Row " & i & " contains the three specified values.") Exit For End If Next i End Sub 

该数组当前将包含列A:C。 如果您有任何问题,请告诉我。