Selection Range of sheets

Dannyh1

Well-known Member
Joined
Nov 18, 2009
Messages
1,144
H

i I think this is a simple one

I am trying to do an activity on range of sheets using "For Each" (sheet in range of sheets)

As a Range would be defined as A1:A100 for eg., how would do you write this for a Range of sheets

1st sheet 'KENNETH WRIGHT', last sheet 'SANDRA WOODS'

Many thanks
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try something like

Rich (BB code):
Dim c As Range, ws As Worksheet
'MasterSheet is the sheet holding the range of sheet names.
For Each c in Sheets("MasterSheet").Range("A1:A100")
    Set ws = Sheets(c.Value)
    'Do stuff using ws as the sheet reference.
    ws.Range("A1").Value = "This is Sheet " & ws.Name
Next c
 
Upvote 0
Hi, Perhaps:-
Code:
[COLOR=navy]Sub[/COLOR] MG03Aug59
[COLOR=navy]Dim[/COLOR] Shts, Sht
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range
Shts = Array("KENNETH WRIGHT", "MICKG", "SANDRA WOOD")
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Sht [COLOR=navy]In[/COLOR] Shts
    [COLOR=navy]With[/COLOR] Sheets(Sht)
        [COLOR=navy]Set[/COLOR] Rng = .Range("A1:A100")
            [COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
                Dn = Sht
                '[COLOR=green][B]Do something Here !![/B][/COLOR]
            [COLOR=navy]Next[/COLOR] Dn
    [COLOR=navy]End[/COLOR] With
 [COLOR=navy]Next[/COLOR] Sht
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,871
Members
449,097
Latest member
dbomb1414

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