Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Question about For Each ws in Worksheets

I have a reporting program I wrote on Excel. Basically, what it does is
generate reports for accounting purposes based on activity. I have a sheet I
want hidden, as no one needs it but me for data validation. Here is a snippet
of my macro:
Private Sub Test()
For Each ws in Worksheets
ws.Activate
[actions]
End Sub
My question is in the ws.Activate line: Using this line, will it activate my
hidden sheet? If so, I can work around that. Thanks.
--
I am running on Excel 2003, unless otherwise stated. Please rate posts so we
know when we have answered your questions. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Question about For Each ws in Worksheets

Never mind. It does activate hidden sheets. I added to my workaround and my
program works fine now.
--
I am running on Excel 2003, unless otherwise stated. Please rate posts so we
know when we have answered your questions. Thanks.


"Orion Cochrane" wrote:

I have a reporting program I wrote on Excel. Basically, what it does is
generate reports for accounting purposes based on activity. I have a sheet I
want hidden, as no one needs it but me for data validation. Here is a snippet
of my macro:
Private Sub Test()
For Each ws in Worksheets
ws.Activate
[actions]
End Sub
My question is in the ws.Activate line: Using this line, will it activate my
hidden sheet? If so, I can work around that. Thanks.
--
I am running on Excel 2003, unless otherwise stated. Please rate posts so we
know when we have answered your questions. Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Question about For Each ws in Worksheets

You could try this. I do agree with Don, I wouldn't think it is neccessary
to activate each sheet to do the actions. It may make your code more
efficient.

' this will exclude the named worksheet
Private Sub Test()
For Each ws in Worksheets
If Not ws.Name Is "Hidden Sheet Name" Then
ws.Activate
[actions]
End If
Next ws
End Sub

or

' this will exclude all hidden worksheets
Private Sub Test()
For Each ws in Worksheets
If Not ws.Visible = False Then
ws.Activate
[actions]
End If
Next ws
End Sub

--
Cheers,
Ryan


"Orion Cochrane" wrote:

I have a reporting program I wrote on Excel. Basically, what it does is
generate reports for accounting purposes based on activity. I have a sheet I
want hidden, as no one needs it but me for data validation. Here is a snippet
of my macro:
Private Sub Test()
For Each ws in Worksheets
ws.Activate
[actions]
End Sub
My question is in the ws.Activate line: Using this line, will it activate my
hidden sheet? If so, I can work around that. Thanks.
--
I am running on Excel 2003, unless otherwise stated. Please rate posts so we
know when we have answered your questions. Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Question about For Each ws in Worksheets

I like that second example excluding the hidden sheets. There was only one
hidden sheet in my actual program, and the sheet name was short, so I
excluded that sheet. Thanks, though. I am sure I will need that example
elsewhere.
--
I am running on Excel 2003, unless otherwise stated. Please rate posts so we
know when we have answered your questions. Thanks.


"RyanH" wrote:

You could try this. I do agree with Don, I wouldn't think it is neccessary
to activate each sheet to do the actions. It may make your code more
efficient.

' this will exclude the named worksheet
Private Sub Test()
For Each ws in Worksheets
If Not ws.Name Is "Hidden Sheet Name" Then
ws.Activate
[actions]
End If
Next ws
End Sub

or

' this will exclude all hidden worksheets
Private Sub Test()
For Each ws in Worksheets
If Not ws.Visible = False Then
ws.Activate
[actions]
End If
Next ws
End Sub

--
Cheers,
Ryan


"Orion Cochrane" wrote:

I have a reporting program I wrote on Excel. Basically, what it does is
generate reports for accounting purposes based on activity. I have a sheet I
want hidden, as no one needs it but me for data validation. Here is a snippet
of my macro:
Private Sub Test()
For Each ws in Worksheets
ws.Activate
[actions]
End Sub
My question is in the ws.Activate line: Using this line, will it activate my
hidden sheet? If so, I can work around that. Thanks.
--
I am running on Excel 2003, unless otherwise stated. Please rate posts so we
know when we have answered your questions. Thanks.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking Worksheets question Dave Excel Discussion (Misc queries) 1 October 8th 08 09:40 PM
VBA question about selecting worksheets jlclyde Excel Discussion (Misc queries) 3 April 17th 08 04:39 PM
Question : Workbooks or Worksheets? WTG Excel Worksheet Functions 1 March 1st 06 09:14 PM
Help! Question about Worksheets.Copy bigfatdummy[_2_] Excel Programming 1 February 25th 06 01:29 AM
Question about worksheets in an AddIn 42N83W Excel Programming 4 April 16th 05 06:40 PM


All times are GMT +1. The time now is 05:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"