当我尝试运行该函数时,弹出的宏菜单下方,因此我创建了一个Sub来调用该函数,现在出现错误“参数不可选”。
该函数正在尝试进行匹配,然后希望用于进行数组索引匹配。 https://bettersolutions.com/vba/arrays/searching.htm
Sub Repossession_Match()
Dim Inflation_Bucket, Inflation_Bucket_Label As Variant
Call TwoDimensional
End Sub
Public Function TwoDimensional(ByVal Inflation_Bucket_Label As Variant, _
ByVal Inflation_Bucket As Variant) _
As Boolean
Dim Inflation_Bucket, Inflation_Bucket_Label As Variant
Inflation_Bucket = Range("Costs.Inflation_Bucket")
Inflation_Bucket_Label = Range("Inflation.Inflation_Bucket_Label")
Dim lrow As Long
Dim lcolumn As Long
For lrow = LBound(Inflation_Bucket_Label, 1) To UBound(Inflation_Bucket_Label, 1)
For lcolumn = LBound(Inflation_Bucket_Label, 2) To UBound(Inflation_Bucket_Label, 2)
If (Inflation_Bucket_Label(lrow, lcolumn) = Inflation_Bucket) Then
TwoDimensional = True
Exit Function
End If
Next lcolumn
Next lrow
End Function
答案 0 :(得分:0)
您想要更多类似这样的东西:
Sub Repossession_Match()
Dim Inflation_Bucket, Inflation_Bucket_Label As Variant
Inflation_Bucket = Range("Costs.Inflation_Bucket")
Inflation_Bucket_Label = Range("Inflation.Inflation_Bucket_Label")
MsgBox TwoDimensional(Inflation_Bucket_Label, Inflation_Bucket)
End Sub
Public Function TwoDimensional(ByVal Inflation_Bucket_Label As Variant, _
ByVal Inflation_Bucket As Variant) _
As Boolean
Dim lrow As Long
Dim lcolumn As Long
For lrow = LBound(Inflation_Bucket_Label, 1) To UBound(Inflation_Bucket_Label, 1)
For lcolumn = LBound(Inflation_Bucket_Label, 2) To UBound(Inflation_Bucket_Label, 2)
If (Inflation_Bucket_Label(lrow, lcolumn) = Inflation_Bucket) Then
TwoDimensional = True
Exit Function
End If
Next lcolumn
Next lrow
End Function