Saving a file as an Excel file while looping in VBA

Symon_J_Turner101

New Member
Joined
Nov 2, 2015
Messages
1
I have written some code that uses the copy to new sheet function in excel a very format heavy tab. I then have written some code to save said tab and some other code to update some values in the original sheet and alter the country loop through it saving the file each time.

Each bit of the code works but when I run it together it breaks. Half the trouble I think is you can'tr pre name the sheet created by the copy to new workbook function.

This is the saving macro

Sub Save_2_Excel()


Dim Ref As String
Dim St As String
Dim En As String
Dim Ex_Ref As String


FilePath = "P:\Hyundai\Hyundai GLOBAL\Country folders\EUROPE\A3 Ops reports"


Sheets("Dashboard - ENG").Select
Sheets("Dashboard - ENG").Copy


Cells.Select
Range("C1").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

Ex_Ref = Sheets("Dashboard - Eng").Range("L1")
St = FilePath + "\Dashboard - ENG"
Ref = Format(DateAdd("m", -1, Now()), "yyyymm")
En = ".xlsx"


ChDir FilePath
ActiveWorkbook.SaveAs Filename:=St & " " & " " & Ex_Ref & " " & Ref & En

ActiveWorkbook.Theme.ThemeColorScheme.Load ( _
"C:\Program Files (x86)\Microsoft Office\Document Themes 15\Theme Colors\Office 2007 - 2010.xml" _
)



ActiveWindow.Close





End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,215,043
Messages
6,122,816
Members
449,095
Latest member
m_smith_solihull

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