Macro to save Spreadsheet as CSV file

vman5781

Board Regular
Joined
Dec 9, 2015
Messages
59
Hi all,

I have the below macro to process a expense payments and i want to add one more step or as a another Macro (if part of this one I need it to pause for employee to check for errors in spreadsheet.)

The additional step is to save tab "Treasury Master" as a .csv file to a designated folder and naming as "MMDDYYTreasury Manager Upload" MMDDYY for current day

Any help would be appreciated -- also is there any redundancy in the below Macro that could be removed?

Thank you


Sub Macro1()
'
' Macro1 Macro
'

'
Range("B2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[1],"", "",DN)"
Range("B2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[1],"", "",RC[2])"
Range("B2").Select
Selection.Copy
Range("B3:B100").Select
ActiveSheet.Paste
Range("B2").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("H2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(RC[-2],'CONCUR DOWNLOAD'!C[21]:C[22],2,FALSE)"
Range("H2").Select
Selection.AutoFill Destination:=Range("H2:H100")
Range("H2:H100").Select
Range("I2").Select
ActiveCell.FormulaR1C1 = "=IF"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]>0,""CR"",""DR"")"
Range("I2").Select
Selection.AutoFill Destination:=Range("I2:I100")
Range("I2:I100").Select
Columns("E:E").Select
Selection.NumberFormat = "000000000"
Range("F17").Select
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
How about:
VBA Code:
Sub SaveAsCSV()

    Dim sMyFolder   As String
    Dim sMyFile     As String

    sMyFolder = "C:\user\designated folder"
    sMyFile = Format(Date, "mmddyy") & "Treasury Manager Upload.csv"

    ThisWorkbook.Sheets("Treasury Master").Copy
    ActiveWorkbook.SaveAs Filename:=sMyFolder & "\" & sMyFile, FileFormat:=xlCSVMSDOS, CreateBackup:=False

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,174
Members
449,071
Latest member
cdnMech

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