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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
How are you trying to hide the tab?

Code or manually?

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

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
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

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
What's the error and how is the macro you mentioned involved?
 
Upvote 0

Domski

Well-known Member
Joined
Jan 18, 2005
Messages
7,292
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

MarkAndrews

Well-known Member
Joined
May 2, 2006
Messages
1,970
Office Version
  1. 2010
Platform
  1. Windows
Or

Before the paste sequence

Sheets("Sheetname").visible = true

After paste

Sheets("sheetname").visible = false

???
 
Upvote 0

goofy78270

Well-known Member
Joined
May 16, 2007
Messages
555
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,191,367
Messages
5,986,249
Members
440,013
Latest member
DBB1

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
Top