Can anyone help me bout this code? I'm juz a beginner of this macro & i really don't have idea about this programming language so i juz search some codes from the internet and try to make it on my own to do the task given to us.
My problem is that when i click the save button, the date repeats..
E.g the filename of the worksheet is ABC_01-31-11 then when i click again the save button, the name of the worksheet is now HRT_01-31_11 01_31-11
This is the Code:
Private Sub SAVE_AS_CSV_Click()
Application.ScreenUpdating = False
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
SaveToDirectory = "C:\Shared\practice\CSV\"
For Each WS In ThisWorkbook.Worksheets
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat
If WS.Name <> "FactData" And WS.Name <> "Menu" And WS.Name <> "Metadata" And WS.Name <> "Distinct Branch" Then
WS.SaveAs SaveToDirectory & WS.Name & Format(Now(), "_mm_dd_yyyy"), xlCSV
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Thank You! your help will be much appreciated...
My problem is that when i click the save button, the date repeats..
E.g the filename of the worksheet is ABC_01-31-11 then when i click again the save button, the name of the worksheet is now HRT_01-31_11 01_31-11
This is the Code:
Private Sub SAVE_AS_CSV_Click()
Application.ScreenUpdating = False
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
SaveToDirectory = "C:\Shared\practice\CSV\"
For Each WS In ThisWorkbook.Worksheets
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat
If WS.Name <> "FactData" And WS.Name <> "Menu" And WS.Name <> "Metadata" And WS.Name <> "Distinct Branch" Then
WS.SaveAs SaveToDirectory & WS.Name & Format(Now(), "_mm_dd_yyyy"), xlCSV
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Thank You! your help will be much appreciated...