VBA Message Box to alter filename when saving

Darren_workforce

Board Regular
Joined
Oct 13, 2022
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a macro file that I setup for my boss that saves a file directly into her folder as "Queue count.xlsx". She then goes and renames it "Queue count [date].xlsx" so that she can keep historical records. My question is: is it possible to have a message box generate which would ask "Date?" and then once the date is entered, it is added onto the filename directly and saved accordingly? Below is the save code I have:

VBA Code:
Sub new_workbook()

Worksheets(Array("Raw paste data", "Q breakdown", "Call vs Staff")).Copy
ActiveWorkbook.SaveAs "G:\Supervisors\Lisa\Queue count" & ".xlsx"

The date format she uses is "m.dd.yy"
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Would the date happen to be in one of the spread sheets?
Offhand, no there are no dates anywhere within the file itself. It's a prior workday, actually and with holidays and weekends, I would be concerned that the date would not always display accurately if I were to try and use a WORKDAY formula.
 
Upvote 0
Try this:
VBA Code:
    Dim dt As String
    Dim fName As String
    
    dt = InputBox("Please enter file date in m.dd.yy format", "FILE DATE ENTRY")
    fName = "G:\Supervisors\Lisa\Queue count " & dt & ".xlsx"

    Worksheets(Array("Raw paste data", "Q breakdown", "Call vs Staff")).Copy
    ActiveWorkbook.SaveAs fName
 
Upvote 0
Solution
This should work, since you are entering as a string, not an actual date.
VBA Code:
Dim s As String
s = Application.InputBox("enter date")
Worksheets(Array("Raw paste data", "Q breakdown", "Call vs Staff")).Copy
ActiveWorkbook.SaveAs "G:\Supervisors\Lisa\Queue count" & s & ".xlsx"
 
Upvote 0
Try this:
VBA Code:
    Dim dt As String
    Dim fName As String
   
    dt = InputBox("Please enter file date in m.dd.yy format", "FILE DATE ENTRY")
    fName = "G:\Supervisors\Lisa\Queue count " & dt & ".xlsx"

    Worksheets(Array("Raw paste data", "Q breakdown", "Call vs Staff")).Copy
    ActiveWorkbook.SaveAs fName
That does exactly what I was hoping it would. Thank you, Joe!
 
Upvote 0
You are welcome.
Glad we were able to help!
 
Upvote 0
This should work, since you are entering as a string, not an actual date.
VBA Code:
Dim s As String
s = Application.InputBox("enter date")
Worksheets(Array("Raw paste data", "Q breakdown", "Call vs Staff")).Copy
ActiveWorkbook.SaveAs "G:\Supervisors\Lisa\Queue count" & s & ".xlsx"
The date box pops up but after I enter the date, the file gets saved as "queue count" but it doesn't add the date into the filename.
 
Upvote 0

Forum statistics

Threads
1,215,108
Messages
6,123,132
Members
449,098
Latest member
Doanvanhieu

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