Hi,
I have two workbooks, one a main Tracker and the other a template that is populated with data then saved. I'm writing the code to reside in the main tracker but reference and manipulate the template as required.
In order to keep the code tidy and more readable I'm trying to declare a couple of workbook variables and then worksheets variables to act as shorthand when specifying ranges across the two workbooks.
I can set the variable for the tracker as this uses the Thisworkbook property but I'm getting a 'subscript out of range' error on the template one:
Dim TrackerWB as workbook, PymtTLWB as workbook
Set TrackerWB = ThisWorkbook 'works
Set PymtTLWB = Workbooks("PT Template") 'doesn't work
I'm guessing I somehow have the syntax wrong but can't quite work it out. I've also run the code with just the Tracker open and with both the Tracker and the Template open, but it makes no difference.
Ideally, I'd like to get the workbook name from a full filepath held in a range using a function I have to get the file name from a file path (this on it's own works fine, but same error when combined with the workbook variable) but I figure one step at a time!
As always, any help appreciated.
Thanks, TC
Bookmarks