Select First Worksheet

  • Thread starter Thread starter halem2
  • Start date Start date
H

halem2

Hi:

I have a macro that sorts worksheets regardless of how many sheets. I
need to have the first sheet selected after the sorting is done.

So, if before the sort I have sheets

5 3 8 2 4

After the sort I have

2 3 4 5 8

but the last sheet (8) is selected automatically. I need to have the
first sheet (in this case 2) selected instead. The first sheet will
have different names.

thanks!
 
Hi

you can refer to it by its index number ... AFAIK excel always counts the
sheets from the left, so the first sheet can be refered to as

Sheets(1).activate

Regards
JulieD
 
Hi Julie,

"excel always counts the sheets from the left, so the first sheet" is
something new to me.
To understand and verify the same in a workbook with 3 sheets A, B and C (in
that order from left to right) I interchanged positions of A and C and
checked VB editor (in the project window) on how these sheets are referred
as. It said Sheet1(A), Sheet2(B) and Sheet3(C). Why didnt it get updated to
Sheet1(C), Sheet2(B) and Sheet3(A).

Then I saved the sheet and checked again but it showed Sheet1(A), Sheet2(B)
and Sheet3(C). Then I closed and reopened the workbook and now the VB editor
showed it as Sheet1(C), Sheet2(B) and Sheet3(A).

Why the lag in time in updation of the project window?

Surprisingly if I have the following then whenever I interchange the sheets
the present left most only gets highlighted!!

Sub try()
Sheets(2).Activate
End Sub


Regards,
Hari
India

JulieD said:
Hi

you can refer to it by its index number ... AFAIK excel always counts the
sheets from the left, so the first sheet can be refered to as

Sheets(1).activate

Regards
JulieD
 
Hi,

A typo in sheet number of sub

Sheets(1).Activate

Regards,
Hari
India

Hari said:
Hi Julie,

"excel always counts the sheets from the left, so the first sheet" is
something new to me.
To understand and verify the same in a workbook with 3 sheets A, B and C (in
that order from left to right) I interchanged positions of A and C and
checked VB editor (in the project window) on how these sheets are referred
as. It said Sheet1(A), Sheet2(B) and Sheet3(C). Why didnt it get updated to
Sheet1(C), Sheet2(B) and Sheet3(A).

Then I saved the sheet and checked again but it showed Sheet1(A), Sheet2(B)
and Sheet3(C). Then I closed and reopened the workbook and now the VB editor
showed it as Sheet1(C), Sheet2(B) and Sheet3(A).

Why the lag in time in updation of the project window?

Surprisingly if I have the following then whenever I interchange the sheets
the present left most only gets highlighted!!

Sub try()
Sheets(2).Activate
End Sub


Regards,
Hari
India
 

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

Back
Top