Selecting a hidden sheet VBA

BenNV

Board Regular
Joined
Mar 27, 2002
Messages
160
Hello!

I use the following command in VBA:
Sheets("Sheet1").Select

But I would like to hide sheet1. What changes do I make to the code as I get many code errors.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi,

Try one of these:

Worksheets("Sheet1").Visible = False
'normal Hide, or
Worksheets("Sheet1").Visible = xlVeryHidden
'very hidden

HTH
 
Upvote 0
thanks Ritchie. I've managed to hide the sheet. But in my code I previously used: Sheets("Sheet1").Select and now that I have hidden Sheet1 the code doesn't work.
 
Upvote 0
On 2003-01-13 10:13, BenNV wrote:
... I've managed to hide the sheet. But in my code I previously used: Sheets("Sheet1").Select and now that I have hidden Sheet1 the code doesn't work.

You can't select or activate a sheet that is hidden. However, you don't usually need to do this in order to carry out an action on a sheet. What are you trying to do?
 
Upvote 0
I am trying to do various selections, pastes, copying, and calculations on particular sheets, which is why I'm trying to select the sheet beforehand.

Maybe I should make the sheet visible before and then once the code is finished, change it to hide.
 
Upvote 0
Hi Ben,

You have two options.

1. As you said, carry out your actions first and then hide the sheet.

2. Just work with the sheet rather than selecting or activating it. This is the preferred method. Eg.
<pre>Sub Test()

With Worksheets("Sheet1")
.Visible = False
'normal Hide
.Range("A1:F20").Copy
End With

Worksheets("Sheet2").Range("A1").PasteSpecial

End Sub</pre>HTH
 
Upvote 0
Hello!

I use the following command in VBA:
Sheets("Sheet1").Select

But I would like to hide sheet1. What changes do I make to the code as I get many code errors.
Hello - i am stacked with same Problem - have you found a solution ?
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,248
Members
451,756
Latest member
tommyw

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