Save As Worksheet with date

M_S

New Member
Joined
Aug 6, 2021
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm trying to 'save as' a worksheet to a specific folder with date in the name. So, my filename is going to say "081921_Bill_Review", what I'm trying to do is if I run this Macro the same, I want excel to create another filer with maybe an additional letter with the date (for e.g: 081921A_Bill_Review), instead of overwriting the previous file.

wb.SaveAs "N:\Team\XYZ\00-Folders\Log" & "/" & Format(Date, "mmddyy") & "_" & "Bill_Review" & ".xlsx"
wb.Close True

Thank you!
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
With the following, if "081921_Bill_Review" already exists, create
"081921A_Bill Review", if "081921A_Bill_Review" already exists, then create
"081921B_Bill_Review" and so on.

VBA Code:
  Dim sPath As String, sDate As String, sName As String, sd2 As String
  Dim n As Long
  
  sPath = "N:\Team\XYZ\00-Folders\Log\"
  sDate = Format(Date, "mmddyy")
  sd2 = sDate
  sName = "_Bill_Review.xlsx"
  n = 64
  Do While True
    If Dir(sPath & sd2 & sName) = "" Then
      Exit Do
    End If
    n = n + 1
    sd2 = sDate & Chr(n)
  Loop
  wb.SaveAs sPath & sd2 & sName
  wb.Close False
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,617
Latest member
Narendra Babu D

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