Hiding a tab

goofy78270

Well-known Member
Joined
May 16, 2007
Messages
555
I am trying to hide a tab within a workbook but it is giving me an error because I am using a macro to copy information for this sheet from another book. How can I unhide and then hide the sheet within the macro or is there another way to do this?
 
You don't need the with statment, paste special behaves a little different to paste in VBA so this should work:

Code:
Sub PastetoMatrixWorkbook()

Application.ScreenUpdating = False

If isWorkbookOpen("Matrix.xls") = False Then Workbooks.Open Filename:="C:\Matrix.xls"

Workbooks("EMPSEC Data.xls").Sheets("Drop-Down Data").Cells.Copy

Workbooks("Matrix.xls").Sheets("Drop-Down Data").Range("A1").PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

Workbooks("EMPSEC Data.xls").Sheets("Matrix Results").Cells.Copy

Workbooks("Matrix.xls").Sheets("Matrix Results").Range("A1").PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

With Workbooks("Matrix.xls")

    .Save
    .Close

End With

Application.ScreenUpdating = True

End Sub


Function isWorkbookOpen(workbookName As String) As Boolean
On Error Resume Next
isWorkbookOpen = (Workbooks(workbookName).Name = workbookName)
On Error GoTo 0
End Function

Dom
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

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