VBA Macro Save File Based On Cell Value in Current Excel Version Issue

pip74205

New Member
Joined
Feb 7, 2017
Messages
16
PHP:
Dim Path As StringDim Filename As String
Path = "C:\Report\"
Filename = Range("B4")
ActiveWorkbook.SaveAs Filename:=Path & Filename & ".xlsx", FileFormat:=xlNormal

I am self teaching myself VBA and have run into an issue. Despite spending a lot of time searching, I wasn't able to get this macro to work correctly.
The above code was the only VBA code for saving a file that didn't immediately fail on me. Despite this, there are 3 issues that I can't figure out how to solve.
Thank you for any help you can provide.

First, the macro fails if I use a formula to include the date in the referenced cell, B4. (I wrapped the date formula in the Text formula so that it would appear correctly in text format).

Second, The window, "Microsoft Excel - Compatibility Checker", pops up and I do not know if it will cause any issues with the saved report. I'm unsure why it won't just save in the same version of Excel that I am using.
compatibilitycheckerdialog.png



Third, I get a pop up saying "Defined names or formulas in this workbook may display different values when they are calculated in an earlier version of excel if they..."
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
How about
Code:
Dim Path As String
Dim Filename As String
Path = "C:\Report\"
Filename = Format(Range("B4"), "[COLOR=#ff0000]dd-mm-yyyy[/COLOR]")
ActiveWorkbook.SaveAs Filename:=Path & Filename & ".xlsx", FileFormat:=51
change the date format to suit
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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