I'm using Application.Match and expecting
Application.Match(["Search Term"],["Search Array"],["-1 Optional Argument
to show the first result higher than 'Search Term'"]
I'm getting a type mis-match error, despite the fact that manually searching that same array will show up a number of examples that I believe should satisfy the script!
For Example:
Sheets("StockPointsLog").Range("E75").Value = 853.45
ReferenceTargetSell = 850.605
I've tried using '''Application.WorksheetFunction.Match''' to see if this fixes the problems that I'm suffering, but this doesn't seem to be a 100% reliable method, so I would prefer to abandon it in favour of an actual solution.
I've tried encapsulating this line in '''CDbl()''' which simply converts the error code into a number.
I have also tried to manually edit values in the array, in order to confirm that I DEFINITELY have a valid result to show, but to no avail.
As you can see I'm error handling for if there is no result (which for the sake of the rest of my Sub is a valid outcome). Which means that the actual outcome for me is that the .match result comes out to = 0, rather than N/A.
I've been googling madly now for 2 days, and I am having to resort to begging you, my dear smart friends for your help and experience!
i = 2
Do While i <= (TotalTrades + 1)
ReferenceDateRow = Application.Match(ReferenceDate,
Sheets("StockPointsLog").Range("A1:A1000"), 0)
ReferenceTargetSell = Sheets("Trades").Range("B" & i).Value
On Error Resume Next
NewTradeDate = Application.Match(ReferenceTargetSell,
Sheets("StockPointsLog").Range("E" & ReferenceDateRow & ":E1001"), -1)
NewTradeDate = Sheets("StockPointsLog").Range("A" & NewTradeDate).Value
ReferenceDateRow comes back with a legitimate and correct value. Happy with that.
ReferenceTargetSell also works as expected.
The issue starts when I'm trying to set NewTradeDate