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

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
 
K

Ken Snell

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top