Match worksheet function in VBA searching on multiple criteria
https://onedrive.live.com/view.aspx?...OsKMFNy3gfzCis
I have a spreadsheet of currency trading data. (link to sample attached) I want to return the close value (F column) having found the correct Date (A column) and Time (B column).
I have a cell formula which works in the Excel spreadsheet. =Index((F2:F34),Match(K2&K3,A2:A34&B2:B34),0)
Where K2 and K3 are the date and time combination I am looking for.
I would like to get this into vba so I can enter the Date and Time as variables.
So far I cannot get this into vba. I have broken down the formula into component steps to see where the issue lies.
Index works ok: Selection.Value = WorksheetFunction.Index(Range("F2:F34"), 19) 'returns the 19th value in the Range. So far so good.
The Match function works well like this with only one column (Date) being searched.
Selection.Value = WorksheetFunction.Match(Range("K2"), Range("A2:A34"), 0) 'returns the date searched for from a column of dates
I however get a compile error when I try to search on two columns, namely Date and Time
Selection.Value = WorksheetFunction.Match(Range("K2") & Range("K3"), Range("A2:A34") & Range("B2:B34"), 0)
Is there a way to use the Match WorksheetFunction to search on multiple criteria in vba?
Thank you.