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?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
How are you trying to hide the tab?

Code or manually?

If it's via code please post the code.
 
Upvote 0
Hi,

I think you'll only get an error if you are trying to select cells on the hidden sheet which is almost always unnecessary. You should be able to paste information to the sheet without actually selecting the cells.

Dom
 
Upvote 0
What's the error and how is the macro you mentioned involved?
 
Upvote 0
Assuming Sheet2 is the hidden sheet you can do it like this without selecting the cells:

Code:
Sub test()

Sheets("Sheet1").Range("A1").Copy

With Sheets("Sheet2")

.Paste Destination:=.Range("A1")

End With

End Sub

Dom
 
Upvote 0
Or

Before the paste sequence

Sheets("Sheetname").visible = true

After paste

Sheets("sheetname").visible = false

???
 
Upvote 0
This is what I currently have. I am not familiar with the With statement but this is what I currently have. The sheets.visible did not seem to work for me.

Code:
Sub PastetoMatrixWorkbook()
    Sheets("Drop-Down Data").Select
    Cells.Select
    Selection.Copy
    ChDir "H:\Secondary\Product Development\Product Matrices"
    Workbooks.Open Filename:="H:\Secondary\Product Development\Product Matrices\Matrix.xls"
Windows("Matrix.xls").Activate
    Sheets("Drop-Down Data").Select
    Cells.Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
Windows("EMPSEC Data").Activate
    Sheets("Matrix Results").Select
    Cells.Select
    Selection.Copy
Windows("Matrix.xls").Activate
    Sheets("Matrix Results").Select
    Cells.Select
    ActiveSheet.Paste
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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