Saving files

K

Kathy

I want to create a file so that when the user saves it
(with in a macro) it sequentally names the file

first save File1.xls, then file2.xls, file3.xls

The #'s 1, 2,3 are part of the worksheet, but I do not
know who to get that # to be part of the file name with
asking the user to do a file saveas file#

please advise
thanks
 
S

speidlbacsi

try this; you may define variables more precisely

Sub SavContinous()

Y = "C:\temp\FileName" ' can be whichever existing folder
For Nr = 1 To 9999

Fname = Y & Nr & ".xls"

Set fs = CreateObject("Scripting.FileSystemObject")
A = fs.FileExists(Fname)

If A = False Then GoTo rutin

Next Nr

rutin:

ActiveWorkbook.SaveAs Filename:=Fname

End Sub
 
Top