Save individual tabs (worksheets) as filename= "Text" + worksheet name + Now - dd.mm.yyy

Dave01

Board Regular
Joined
Nov 30, 2018
Messages
116
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi,

Thanks for anyones help here,

I have a workbook with multiple (just two for now) name tabs / worksheets, I would like to save these individual tabs / worksheets as a separate file as a CSV, but I would like to call each CSV as

text + tab name + date

so eg - Test 1_Test_2_SSS1-CHF-22.08.22

Hers the code I have but, its causes errors, seems to be an issue when I introduced the SName & DTE, can anyone help me get it working

Link for sharing test macro


Many thanks

Dave.


Sub Macro10()
'
' Macro10 Macro

Application.DisplayAlerts = False
Application.CutCopyMode = False 'Clearing the Office Clipboard
Application.ScreenUpdating = False ' This turns the screen updating off while the macro runs, helps with speed
Application.EnableEvents = False ' Disables events, so commands where you need to press OK


'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'Create Temp Output file & remove redundant worksheets
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


Dim WB As Workbook
Dim WS As Worksheet
Dim FolderPath, FileName, SName, DTE As String

DTE = Format$(Now, " - dd.mm.yyyy")
FolderPath = "C::\Temp\test"
SName = "Test1_Test2_ "

For Each WS In Worksheets
WS.Copy
Set WB = ActiveWorkbook
SName = "Test1_Test2_ "
FileName = SName & WS.Name & DTE
WB.SaveAs FileName:=FolderPath & "\" & FileName, FileFormat:=xlCSV
Application.DisplayAlerts = False
WB.Close
Application.DisplayAlerts = True
Next WS



Application.DisplayAlerts = True
Application.CutCopyMode = False 'Clearing the Office Clipboard
Application.ScreenUpdating = True ' This turns the screen updating off while the macro runs, helps with speed
Application.EnableEvents = True ' Disables events, so commands where you need to press OK

End Sub
 

Attachments

  • error.JPG
    error.JPG
    136.7 KB · Views: 5

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
would you believe double :

FolderPath = "C::\Temp\test"

ok fixed

thanks
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,678
Members
449,116
Latest member
HypnoFant

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