Dynamic filename
"pikus <" wrote...
Alright, I know what you're asking. Do it like this:
foo = ThisWorkbook.Name
Workbooks(foo).Worksheets("Sheet1) blah blah blah...
And if the OP then runs
Workbooks(foo).SaveAs Filename:=SomethingWithDifferentBaseFilename
the next time statement referencing Workbooks(foo) will throw a runtime error.
Using workbook-type object variables tracks the workbook as long as it's open.
--
To top-post is human, to bottom-post and snip is sublime.
|