I'm trying to create a macro to help make a manual commission process go faster. I ran into an issue with one of the formulas in the process when creating the macro.
To give more context, a report is run with one tab labelled "Data" with all the sales transactions. The retail team keeps a separate Excel file to house all transactions from the past year in order to help filter returns that are older than 2 weeks. They copy the ISO sheet to the main report and use the following formula:
=IFERROR(IF(S2<0,VLOOKUP(P2&0,'ISO History 2.3'!U:V,2,0),0),0)
In the VBA code, it looks like this:
=IFERROR(IF(RC[-2]<0,VLOOKUP(RC[-5]&0,'ISO History 2.3'!C:C[1],2,0),0),0)
The ISO tab name is always changed with the most recent date of transactions they have. When I created the macro, it recorded the current name of the ISO tab. Is there a different way to refer to the sheet? It's always placed after the "Data" tab, so I was wondering if there's a way to refer to the next tab in the macro.
Worksheets have a Next
and a Previous
property. If there's no "next" or "previous" sheet then these properties return Nothing
.
Worth noting though that (eg) Next
will happily return a Chart sheet if that's the next one to the right, so depending on your use case it might be worth adding in a check for that.