View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Harlan Grove[_5_] Harlan Grove[_5_] is offline
external usenet poster
 
Posts: 97
Default 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.