更新时间:2022-11-14 14:50:01
I found out by doing via vlookup instead of dictionary.
However, if you know the answer via dictionary, I'd like to learn too.
Below is the code that I've done via vlookup
For Each profitCentre In myProfitCentreArray
If profitCentre <> "" And Not profitCentre Like "####0000" Then
With Workbooks(wbPropListing).Sheets("Residential")
Set lookupResRange = .Range("E3:F" & .Cells(Rows.Count, "E").End(xlUp).row)
End With
With Workbooks(wbPropListing).Sheets("Fund&CoT")
Set lookupFundRange = .Range("E2:F" & .Cells(Rows.Count, "E").End(xlUp).row)
End With
lookupResult = Application.VLookup(CStr(profitCentre), lookupResRange, 2, False)
If IsError(lookupResult) Then
lookupResult = Application.VLookup(CStr(profitCentre), lookupFundRange, 2, False)
If IsError(lookupResult) Then MsgBox "Profit Centre: " & profitCentre & " Not Found"
End If
myforecastSheetsIndex = myforecastSheetsIndex + 1
End If
Next profitCentre