Hi all,
Im not great at VBA by any means but since moving to mac I cant seem to do anything i used to do with ease.
I am simply trying to create a macro that copies a sheet in my active workbook to a new .csv file with that sheet name as the title and todays date and time in the newly created filename.
The code below is something i found on this very forum after many hours of searching but it seems to get stuck as 'SaveAs FileName' and excel spits out this error message:
"GROWBOTSSS130719.csv" cannot be accessed. The file may be corrupted, located on a server that is not responding, or read-only."
Sub SAVECSV()
'
Dim MyPath As String
Dim MyFileName As String
'The path and file names:
MyPath = "/Users/joshualally/Documents/SALES DATA/CSV Files/Growbots"
MyFileName = "GROWBOTSSS" & Format(Date, "ddmmyy")
'Makes sure the path name ends with "":
If Not Right(MyPath, 1) = "/" Then MyPath = MyPath & "/"
'Makes sure the filename ends with ".csv"
If Not Right(MyFileName, 4) = ".csv" Then MyFileName = MyFileName & ".csv"
'Copies the sheet to a new workbook:
Sheets("Growbots Ingestion").Copy
'The new workbook becomes Activeworkbook:
With ActiveWorkbook
.SaveAs FileName:= _
MyPath & MyFileName, _
FileFormat:=xlCSV, _
CreateBackup:=False
End With
End Sub
Any help would be really appreciated!
Thanks, Josh
Im not great at VBA by any means but since moving to mac I cant seem to do anything i used to do with ease.
I am simply trying to create a macro that copies a sheet in my active workbook to a new .csv file with that sheet name as the title and todays date and time in the newly created filename.
The code below is something i found on this very forum after many hours of searching but it seems to get stuck as 'SaveAs FileName' and excel spits out this error message:
"GROWBOTSSS130719.csv" cannot be accessed. The file may be corrupted, located on a server that is not responding, or read-only."
Sub SAVECSV()
'
Dim MyPath As String
Dim MyFileName As String
'The path and file names:
MyPath = "/Users/joshualally/Documents/SALES DATA/CSV Files/Growbots"
MyFileName = "GROWBOTSSS" & Format(Date, "ddmmyy")
'Makes sure the path name ends with "":
If Not Right(MyPath, 1) = "/" Then MyPath = MyPath & "/"
'Makes sure the filename ends with ".csv"
If Not Right(MyFileName, 4) = ".csv" Then MyFileName = MyFileName & ".csv"
'Copies the sheet to a new workbook:
Sheets("Growbots Ingestion").Copy
'The new workbook becomes Activeworkbook:
With ActiveWorkbook
.SaveAs FileName:= _
MyPath & MyFileName, _
FileFormat:=xlCSV, _
CreateBackup:=False
End With
End Sub
Any help would be really appreciated!
Thanks, Josh