Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Doing a macro in every worksheet except 2


Hi all,

I have potentailly unlimited worksheets to my database which can be
added at will, but all have a column which is identical except 2.

I need some code that will look at all worksheets except those two and
carry out my macro.

I thought: For Each Sheet In ActiveWorkbook.Sheets would work but i
cant seem to use it for this.

Any help would be appreciated.


--
kanuvas
------------------------------------------------------------------------
kanuvas's Profile: http://www.excelforum.com/member.php...o&userid=27911
View this thread: http://www.excelforum.com/showthread...hreadid=477084

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Doing a macro in every worksheet except 2

You can, but you have to outsort the exceptions, something like

For Each sh In ActiveWorkbook.Sheets
If sh.Name < "name1" Ad sh.Name < "Name2" Then
'do your stuff
End If
Next sh

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"kanuvas" wrote in
message ...

Hi all,

I have potentailly unlimited worksheets to my database which can be
added at will, but all have a column which is identical except 2.

I need some code that will look at all worksheets except those two and
carry out my macro.

I thought: For Each Sheet In ActiveWorkbook.Sheets would work but i
cant seem to use it for this.

Any help would be appreciated.


--
kanuvas
------------------------------------------------------------------------
kanuvas's Profile:

http://www.excelforum.com/member.php...o&userid=27911
View this thread: http://www.excelforum.com/showthread...hreadid=477084



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Doing a macro in every worksheet except 2

Hi Kanuvas,

Try something like:
'==================
Sub Tester()

Dim WS As Worksheet

For Each WS In ActiveWorkbook.Worksheets
If WS.Name < "Sheet3" And WS.Name < "Sheet4" Then
'run your code, e.g.:
MsgBox WS.Name
End If
Next WS

End Sub
'<<==================

Change Sheet3 and sheet 4 to the names of the sheets of interest.

---
Regards,
Norman



"kanuvas" wrote in
message ...

Hi all,

I have potentailly unlimited worksheets to my database which can be
added at will, but all have a column which is identical except 2.

I need some code that will look at all worksheets except those two and
carry out my macro.

I thought: For Each Sheet In ActiveWorkbook.Sheets would work but i
cant seem to use it for this.

Any help would be appreciated.


--
kanuvas
------------------------------------------------------------------------
kanuvas's Profile:
http://www.excelforum.com/member.php...o&userid=27911
View this thread: http://www.excelforum.com/showthread...hreadid=477084



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Doing a macro in every worksheet except 2


Thanks a lot guys both worked wonders

--
kanuva
-----------------------------------------------------------------------
kanuvas's Profile: http://www.excelforum.com/member.php...fo&userid=2791
View this thread: http://www.excelforum.com/showthread.php?threadid=47708

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
Excel Macro Issue Trying to autorun Macro Upon Opening Worksheet wyndman Excel Programming 2 May 25th 04 06:59 PM
How to end macro on inital active worksheet containing macro button that was clicked Silverhawk1 Excel Programming 2 May 14th 04 03:58 PM
How? Macro to copy range to new worksheet, name new worksheet, loop Repoman Excel Programming 9 October 9th 03 01:45 PM
macro to apply worksheet event to active worksheet Paul Simon[_2_] Excel Programming 3 August 7th 03 02:50 AM
Record Worksheet Content as Macro and Execute from another Worksheet David McRitchie[_2_] Excel Programming 2 July 23rd 03 09:43 AM


All times are GMT +1. The time now is 07:56 PM.

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

About Us

"It's about Microsoft Excel"