View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default macro for multiple worksheets

JE

On this topic of Worksheets(Array

What is the syntax for an Array of sheets not by hard-coded name but by
codename?

I know Worksheets(Array(1, 2, 4, 7) allows for renaming the sheets but if the
sheets get re-ordered, the 1,2,4,7 is out of whack.


Gord

On Mon, 21 May 2007 14:04:51 -0600, JE McGimpsey wrote:

Number of worksheets selected (only one can be active at a time):


Dim nSelectedWS As Long
nSelectedWS = ActiveWindow.SelectedSheets.Count

for multiple worksheets:

Dim ws As Worksheet
For Each ws In Worksheets(Array("wks1", "wks3", "wks5"))
'do something with each ws
Next ws


In article ,
Brian wrote:

Is there a way to have a macro span multiple worksheets but not the whole
workbook (i.e wks1,wks3,wks5 only)?

Also, is there a way to determine whether multiple worksheets have been
selected and activated?