Date Format Help

rockchalk33

Board Regular
Joined
Jan 12, 2016
Messages
111
Hey all,

So I'm at the tail end of an enormous project and at the end of a subroutine I have a specific sheet being saved as a PDF. This PDF is representing a group of information based on a specific date entered by the user in the mm/dd/yyyy format. This value is entered at the beginning of the sub routine and is shown here:

Code:
Dim userDate As String
userDate = InputBox("Please type a date to search in MM/DD/YYYY format")

My goal is to have the PDF saved as ......../MM_DD_YYYY because saving it as MM/DD/YYYY obviously creates an error as seen in the code below.

Code:
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "C:\Users\Rocky\Desktop\Devin\Project\" & userDate & ".pdf", Quality:= _
        xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
        OpenAfterPublish:=True

How can I rewrite the above code to satisfy saving the data as well as representing the arbitrary date entered?

Thanks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Untested but try adding the line below...

Code:
Dim userDate As String
userDate = InputBox("Please type a date to search in MM/DD/YYYY format")
[COLOR="#FF0000"]userDate = Replace(userDate, "/", "_")[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,214,989
Messages
6,122,622
Members
449,093
Latest member
catterz66

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