I'm trying to have an excel VBA file create and save a .csv file. The newly created .cvs file should be named after the tab name, and include the current date as the file name. The new .csv should also be saved into the same directory as the VBA file that created it.
I'm putting pieces of code together, but not having much success. Here's what I got so far, but it doesn't work, so I need someone to straighten this out.
Ideally, I'd like for the CVS file to be saved and closed during this process, while leaving the VBA file visible.
Thanks for any assistance.
I'm putting pieces of code together, but not having much success. Here's what I got so far, but it doesn't work, so I need someone to straighten this out.
Ideally, I'd like for the CVS file to be saved and closed during this process, while leaving the VBA file visible.
Thanks for any assistance.
Code:
Sub SaveAsCSV()
Application.DisplayAlerts = False
Dim Name As String
Name = ThisWorkbook.Path & "\" & ActiveSheet.Name & " " & _
Format(Now(), "mm.dd.yy") & ".csv" ' I also tried this---> & FileFormat:=xlCSV, CreateBackup:=False (but it doesnt work)
Application.DisplayAlerts = True
MsgBox "File " & Name & " has been Created and Saved as: " & Name, , "Copy & Save Report"
End Sub