Save as Help VBA

mr_average

New Member
Joined
Aug 10, 2016
Messages
3
Sub SAVEasCSV()
'
' SAVEasCSV Macro
'
' Keyboard Shortcut: Ctrl+Shift+S
'
ChDir "F:\C Store Shared\Credit Cards\Tesoro Connect CSV Credit Card Files"
ActiveWorkbook.SaveAs Filename:=Range("A2")
, FileFormat:=xlCSV, CreateBackup:=False
End Sub


Trying to save as the date in cell A2 I have never really edited VBA.. just always used the macro recorder. Help Please!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try this:
Code:
[COLOR=#333333]Sub SAVEasCSV()[/COLOR]
[COLOR=#333333]'[/COLOR]
[COLOR=#333333]' SAVEasCSV Macro[/COLOR]
[COLOR=#333333]'[/COLOR]
[COLOR=#333333]' Keyboard Shortcut: Ctrl+Shift+S[/COLOR]
[COLOR=#333333]'
[/COLOR]Dim myFileName as String
myFileName = [COLOR=#333333]"F:\C Store Shared\Credit Cards\Tesoro Connect CSV Credit Card Files\" & Range("A2") & ".csv"[/COLOR]
[COLOR=#333333]ActiveWorkbook.SaveAs Filename:=[/COLOR]myFileName[COLOR=#333333], FileFormat:=xlCSV, CreateBackup:=False[/COLOR]
[COLOR=#333333]
End Sub[/COLOR]
Note if your date is formatted with slashes, you may need to change the format in the name, as Excel might not like that, i.e.
change
Code:
Range("A2")
to something like:
Code:
Format(Range("A2"),"mm-dd-yyyy")
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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