PDA

View Full Version : Accessing Worksheets



Prema
03-04-2010, 05:18 AM
Hi All,

May be this is one of the basic question that I am posting. But I am stuck up here only.

I have some random number of worksheets in a workbook with random names.

Can anyone tell me Is there any way to access these sheets individually, excluding first sheet i.e sheet1?

Thanks,

Bob Phillips
03-04-2010, 05:55 AM
With Activeworkbook

For i = 2 To .Worksheets(.Worksheets.Count)

'process .Worksheets(i)
Next i
End With

Prema
03-04-2010, 06:01 AM
Thanks

Paul_Hossler
03-04-2010, 06:48 AM
Just in case the 'First Sheet' is NOT named 'Sheet1', you could just test the name



Option Explicit
Sub drv()
Dim ws As Worksheet

For Each ws In ActiveWorkbook.Worksheets
With ws
If .Name <> "Sheet1" Then

'do stuff
MsgBox .Name

End If
End With
Next

End Sub


Paul

Prema
03-07-2010, 09:23 PM
Thanks a lot.