Hi,
I dont understand why the following codes dont run properly
Function GetSettlementData(SettlementDate, DeliveryDate, Prod, Timeframe)
If Timeframe = "Monthly" And Prod = "Power" Then
With Sheets("Settlement Data")
RowIndex = WorksheetFunction.Match(SettlementDate, .Range("A160:A312"), False)
ColIndex = WorksheetFunction.Match(DeliveryDate, .Range("B159:W159"), False)
GetSettlementData = WorksheetFunction.Index(.Range("B160:W312"), RowIndex, ColIndex)
End With
End If
End Function
Basically, RowIndex and ColIndex are outputs of the function match, and they should be some numeric value. So I feed them into the function Index but it does not properly give me back the correct answer i'm looking for.
What is the problem?
Thanks,
Kim