miketastic
New Member
- Joined
- Apr 8, 2015
- Messages
- 14
Hello! I have a question about this thing I'm working on. I'm trying to SaveAs a single sheet from one workbook to a new workbook as a .cvs file. It will always go to the same place with the same name and overwrite the current file.
So far I have this here, but I'm getting errors where the text is red. The new workbook appears with the correct name, but it doesn't save anywhere.
Help is MUCH appreciated.
So far I have this here, but I'm getting errors where the text is red. The new workbook appears with the correct name, but it doesn't save anywhere.
Help is MUCH appreciated.

Code:
Sub CopyToCSV()
Dim MyPath As String
Dim MyFileName As String
MyPath = "P:\PAYOFFS\XREF Report\"
MyFileName = "CSVUPLOAD"
If Not Right(MyPath, 1) = "\" Then MyPath = MyPath & "\"
If Not Right(MyFileName, 4) = ".csv" Then MyFileName = MyFileName & ".csv"
Sheets("CSV UPLOAD").Copy
With ActiveWorkbook
[COLOR=#ff0000] .SaveAs Filename:=MyPath & MyFileName, FileFormat:=xlCSV, CreateBackup:=False[/COLOR]
.Close False
End With
End Sub