i want to save a filename based on a cell value (AA2 for example) which has date format (dd/mm/yyyy) but i want it to be like yyyymmdd without slash (/). This code works fine but gives me the current date (which doesnt help)
Sub CopyToCSV()
Dim MyPath As String
Dim MyFileName As String
'The path and file names:
MyPath = "C:\Hello"
MyFileName = "Greetings_" & Format(Date, "yyyymmdd")
'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 Hello = Hello & ".csv"
'Copies the sheet to a new workbook:
Sheets("final step").Copy
'The new workbook becomes Activeworkbook:
With ActiveWorkbook
'Saves the new workbook to given folder / filename:
.SaveAs Filename:= _
MyPath & MyFileName, _
FileFormat:=xlCSV, _
CreateBackup:=False, _
Local:=True
'Closes the file
.Close False
End With
End Sub