file name as a variable in "Output to" of macro

  • Thread starter Thread starter Beginner
  • Start date Start date
B

Beginner

I am using a macro embedded in another to output the
different queries to different excel workbooks.

Can the file name in the "output to " action of the macro
be a variable so that I can have different excel files for
the different queries ?

Thanks for any help

Beginner
 
Not a variable, but it can call a function that returns a value, or it can
use a value from a control on a form.

For example,

File Name: ="C:\MyFolder\" & GetANewFileName() & ".xls"

And put this public function in a regular module:

Public Function GetANewFileName As String
GetANewFileName = Format(Now(), "hhnnss")
End Function
 
Back
Top