要搜索的列是A,我想要返回的值来自列B(旁边),但也希望它的单元格地址为B列中的值。
到目前为止,我有以下(到目前为止是B栏中的返回值)
Private Sub CommandButton21_Click()
Dim MatchFormula As Long
Dim IndexFormula As Range
MatchFormula = WorksheetFunction.Match(Range("Today"), Range("A:A"), 0)
Set IndexFormula = WorksheetFunction.Index(Range("B:B"), MatchFormula, 0)
IndexFormula.Value = Range("G5").Value
End Sub
但它说
MatchFormula = WorksheetFunction.Match(Range("Today"), Range("A:A"), 0)
给出此错误
has Run-time error '1004':
Method 'Range' of object'_Worksheet' failed