Can anyone help me with macro? plsssss. thank you:)

Dichi

New Member
Joined
Jan 30, 2011
Messages
4
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...
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
try this change
Code:
WS.SaveAs SaveToDirectory & left(WS.Name,len(WS.Name)-9) & Format(Now(), "_mm_dd_yyyy"), xlCSV
 
Upvote 0
thanks for the help:) much appreciated but I already made it yesterday.. I juz replace x1csv into ".csv" & it works:) but then I'll take note of your advice too... tnx again &
Godbless!:)
 
Upvote 0
do anyone knows how to save sheets w/ end of the month date on the filename? For instance, if I save a specific sheet on feb. 1, 2010 it will automatically save as filename + 02-28-2010.csv



can anyone help me? tnx :)
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top