Code to Select First Sheet??

D

Don

G'day All,

Looking for VBA line to select the first sheet (furthest
sheet to the left) regardless of name of sheet.

I've been able to get there with the following, but was
wondering if there was a one-liner to do the job:

Sub goto_firstsheet()
Dim i As Integer
On Error GoTo XXX
For i = 1 To 100
ActiveSheet.Previous.Select
Next i
XXX:
End Sub

TIA,

Don
 
H

Harald Staff

Hi Don

Sheets(1).Activate

The number used in parentheses is like counting from left to right.
Similar by sheet name:

Sheets("Sheet1").Activate

HTH. Best wishes Harald
 
D

Don

Hi Harald,

Works great.

I knew there had to be a better way....but like most of
this VBA stuff I suffer through the hard way most of the
time in my learning process.

Thanks for the quick reply,

Have a good day,

Don
 
H

Harald Staff

I knew there had to be a better way....but like most of
this VBA stuff I suffer through the hard way most of the
time in my learning process.

We all do. And every unit of knowledge or experience raises two more
questions, so we know less and less when we learn.

Thanks for the feedback.

Best wishes Harald
 

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