In the code below I am running into a error witht he TBWB variable that causes the code to erroro out. I would greatly appreciate help with knowing how to pass the active workbook into a variable. Thanks in advance
Code:
Sub MoveTabs()
Dim TempFilePath As String
Dim TempFileName As String
Dim TBWB
TBWB = ThisWorkbook
TempFilePath = "[URL="file://\\honts8020\S8Data\mdseuser\common\Planning"]\\honts8020\S8Data\mdseuser\common\Planning[/URL] and Analysis\P&L Reporting\P&L Breakdown\"
TempFileName = "P&L Breakdown " & Format(Date, "yyyy-mm-dd") & ".xlsm"
Sheets("byPeriod").Range("A1:AS150").Value = Sheets("byPeriod").Range("A1:AS150").Value
Sheets("Retrieve").Range("A1:Co350").Value = Sheets("Retrieve").Range("A1:CO350").Value
If Sheets("byPeriod").Cells(11, xCol).Value = "LY $" Or _
Sheets("byPeriod").Cells(11, xCol).Value = "Plan $" Or _
Sheets("byPeriod").Cells(11, xCol).Value = "vs Plan %" Or _
Sheets("byPeriod").Cells(11, xCol).Value = "Target $" Or _
Sheets("byPeriod").Cells(11, xCol).Value = "vs Target" _
Then
Sheets("byPeriod").Columns(xCol).EntireColumn.Hidden = True
End If
Sheets(Array("byPeriod", "Retrieve")).Copy
With ActiveWorkbook
.SaveAs TempFilePath & TempFileName, 52
End With
TBWB.Saved = True
frm_Tabs.Hide
End Sub