unique file names

  • Thread starter Thread starter Graeme R
  • Start date Start date
G

Graeme R

hoping someone can help me. I need to find out how to export selecte
data from excel, into a new sheet, and then save numerous times, eac
time with a unique file name. Anyone know what is the easiest way o
doing this? I have macro set up to cut and paste secial data form th
template, but as I am new to this, and frankly dumb, i am havin
trouble finding help on unique file names.

Help is appreciated if available, otherwise insanity looms large!!

Thanks in advanc
 
Assuming you want a meaningful name, the usual approach is to include a
time-stamp as the final part of the name, e.g.

NewName = "MyWorkbook" & Format$(Now(),"yyyymmddhhmmss") & ".xls"

which has a resolution of 1 second. Now, before trying to save with that name,
you use the Dir$ function to see if that name as already been used. If so,
append a letter to make it

NewName = "MyWorkbook" & Format$(Now(),"yyyymmddhhmmss") & "A.xls"

And of course you have to see if that name is available, and if not, go to B,
etc. Generally you would use a loop at this point.
 

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

Back
Top