How do I activate the first worksheet?

G

Guest

I want to activate the first worksheet out of x number in a workbook.
The sheet names will vary every time, so I was wondering how you select the
first sheet using generic code.
Thanks, Mel
 
G

Guest

Excellent, and so simple! Cheers Keith.
Is there a way of activating the last sheet again? There may be any number
of sheets so I guess its not Worksheets(20 or whatever).Activate

Thanks, Mel
 
G

Guest

You might try:

Sub LastSht()
Dim CntSheets As Long

'Activate last worksheet in the workbook
With Application
CntSheets = .Sheets.Count - .Charts.Count
.Worksheets(CntSheets).Activate
End With

End Sub
 
G

Guest

Thanks Chad, that worked great :)

Chad said:
You might try:

Sub LastSht()
Dim CntSheets As Long

'Activate last worksheet in the workbook
With Application
CntSheets = .Sheets.Count - .Charts.Count
.Worksheets(CntSheets).Activate
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top