gleamng
Board Regular
- Joined
- Oct 8, 2016
- Messages
- 98
- Office Version
- 365
- 2021
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- 2003 or older
- Platform
- Windows
- MacOS
- Mobile
- Web
GOOD DAY ALL, I HAVE THIS VBA TO SAVE WORKSHEETS AS WORKBOOKS AND IT WORKS FINE BUT THE PROBLEM I HAVE IS THAT THE MACRO NEEDED TO BE RUN ON ALL OPENED FILE AND AN UNSAVED FILE. SO I WANT VBA TO SAVE TO A FOLDER NAMED VER ON DESKTOP AND I WANT IT TO SAVE THE FILES IN A FOLDER WITH TODAY'S DATE INSIDE VER ON THE DESKTOP.
THANK YOU FOR YOUR HELP, BELOW IS THE CODE
THANK YOU FOR YOUR HELP, BELOW IS THE CODE
VBA Code:
Sub VerSheetsToWorkbooks()
Dim Sheet As Worksheet, SheetName$, MyFilePath$, N&
MyFilePath$ = ActiveWorkbook.Path & "\" & Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 5)
With Application
.ScreenUpdating = False
.DisplayAlerts = False
' End With
On Error Resume Next '<< a folder exists
MkDir MyFilePath '<< create a folder
For N = 1 To Sheets.Count
Sheets(N).Activate
SheetName = ActiveSheet.Name
Cells.Copy
Workbooks.Add (xlWBATWorksheet)
With ActiveWorkbook
With .ActiveSheet
.Paste
.Name = SheetName
[A1].Select
End With
'save book in this folder
.SaveAs Filename:=MyFilePath _
& "\" & SheetName & ".xls"
.Close SaveChanges:=True
End With
.CutCopyMode = False
Next
End With
Sheet1.Activate
End Sub