saving data with a macro

feza

New Member
Joined
Jan 13, 2005
Messages
4
hi, i have this formula already for recording a macro with the date but i was wondering if anyone could adjust it so that it can save more than one different workbooks on the same day

Sub SaveAsTodaysDate()
Dim sFileName As String, sPath As String
sPath = "C:\" 'change path here
sFileName = Format(Now(), "ddmmmyy")
'File =sPath & sFileName Might fit in nice to do this way so you have a varialble to call the file
ActiveWorkbook.SaveAs (sPath & sFileName)
End Sub


would be a great help
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
This Solution adds a version number to the name of the book. It does this by seeing if the file already exists.

Sub SaveAsTodaysDate()
Dim sFileName As String, sPath As String
sPath = "C:\" 'change path here
sFileName = Format(Now(), "ddmmmyy")

' Create A version Number if already exists
Num = 1
Do While Dir(sPath & sFileName & ".xls") <> ""
sFileName = Format(Now(), "ddmmmyy")
Num = Num + 1
VerNum = "_Ver" & Num
sFileName = sFileName & VerNum
Loop

'File =sPath & sFileName Might fit in nice to do this way so you have a varialble to call the file
ActiveWorkbook.SaveAs (sPath & sFileName)
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,483
Messages
6,055,665
Members
444,806
Latest member
tofanexcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top