phyxius117
New Member
- Joined
- May 14, 2024
- Messages
- 6
- Office Version
- Prefer Not To Say
- Platform
- Windows
Hello all,
I have made the following VBA codes to save specific sheets of a workbook to a new workbook. However when I hide the sheets it no longer works. I want to keep those sheets hidden in the current workbook but not in the new workbook.
Here is the code:
Thank you all for any help I can get!!
I have made the following VBA codes to save specific sheets of a workbook to a new workbook. However when I hide the sheets it no longer works. I want to keep those sheets hidden in the current workbook but not in the new workbook.
Here is the code:
VBA Code:
Sub Export()
Dim DCname As String
DCname = ActiveWorkbook.Sheets("Reference").Range("R2").Value
Dim FiscalYear As String
FiscalYear = ActiveWorkbook.Sheets("Reference").Range("R8").Value
Dim Period As String
Period = ActiveWorkbook.Sheets("Reference").Range("R11").Value
Dim FileName As String
FileName = DCname & "_SQL Data_FY" & FiscalYear & "_P" & Period
Worksheets(Array("Route Totals", "Stops")).Copy
With ActiveWorkbook.Worksheets("Route Totals")
.UsedRange.Value = .UsedRange.Value
End With
With ActiveWorkbook.Worksheets("Stops")
.UsedRange.Value = .UsedRange.Value
End With
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & FileName, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
End Sub
Thank you all for any help I can get!!