我正在开发一个Excel项目,我需要导入每月.csv文件,解析这些文件中的列并将相邻列中的数字返回到摘要表中。这是个主意:
1
写入第二个数组(名为arrTrueFalse
)0
写入arrTrueFalse
SUMPRODUCT
这是代码,我会尝试标记它破坏的地方
Private strBaba As String
Private arrCampaigns() As Variant
Private arrAmounts() As Variant
Private arrTrueFalse() As Variant
Public Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean
IsInArray = Not IsError(Application.Match(stringToBeFound, arr, 0))
End Function
Public Sub stringComparison()
Dim i As Long, j As Long
j = 1
Call OptimizeCode_Begin
With Sheet14
arrCampaigns = .Range("F2:F1000").Value
arrAmounts = .Range("I2:I1000").Value
End With
ReDim arrTrueFalse(1 To UBound(arrCampaigns) - LBound(arrCampaigns) + 1, 1 To 1)
For i = 2 To Sheet2.Cells(Sheet2.Rows.Count, 1).End(xlUp).Row
strBaba = Sheet2.Range("A" & i).Value & "*" & Sheet2.Range("C" & i).Value & "*"
Call IsInArray(strBaba, arrCampaigns)
'=> Works up to this line (where I call IsInArray); after that, loop never gets executed?
If IsInArray(strBaba, arrCampaigns) = True Then
arrTrueFalse(j) = 1
Else
arrTrueFalse(j) = 0
End If
j = j + 1
Next i
Call OptimizeCode_End
End Sub
我做错了什么?