Passing Active Workbook into a variable

Temo98

New Member
Joined
Oct 23, 2009
Messages
45
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
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,224,527
Messages
6,179,351
Members
452,907
Latest member
Roland Deschain

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