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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,215,170
Messages
6,123,422
Members
449,099
Latest member
COOT

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