Is there Existing code for such?

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
My Wb has 100 sheets in it. Named R001 to R100. They are in consequtive order. When I activate (thru code) say the sheet named R075 - How can I (thru code) have this sheet (R075) in the First position of the Sheet tab names across the bottom of the screen? I've been looking on the net for this now for an hour without success. Does anyone have anything close to this?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Fowmy

Well-known Member
Joined
Jul 10, 2008
Messages
512
Office Version
  1. 365
Platform
  1. Windows
Try this macro

Code:
Sub ActSht()
  Sh = InputBox("Enter Sheet name")
  (Sh).Move Before:=Sheets(1)
End Sub
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try this in the ThisWorkbook module


Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Me.Move before:=Sheets(1)
End Sub
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,343
Office Version
  1. 365
Platform
  1. Windows
Jim

You could try using the Workbook SheetActivate event.
Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
    Sh.Move Before:=Worksheets(1)
End Sub
Mind you I don't quite know exactly how, or even if, that will affect the order of the other sheets.
 

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484

ADVERTISEMENT

Thanks Guys;
In all cases (3) after returning to my Master Sheet (ws #1) the R075 is now next to my Master Sheet in Position 2, instead of R001 being in position 2. PLUS somehow the 3rd position is R100, the 4th R099 (descending order)????
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,343
Office Version
  1. 365
Platform
  1. Windows
Jim

You didn't mention a master sheet or what you want to happen when you activate any other sheet.

It's probably possible to 'return' it to it's original position but that might not be straightforward.

Excel has no built-in functionality for ordering worksheets by name, if you wanted to do that you would need other code.

Why do you want to move the worksheet anyway?

Couldn't you just hide all other non-relevant worksheets?

Then unihide once you've done what you want to do.
 

Cindy Ellis

MrExcel MVP
Joined
Jun 9, 2006
Messages
1,802
I'm interpreting the question a bit differently...rather than moving the worksheet, that you just want to scroll the tabs so that the desired sheet is the first on the left, and is active.
If so, try the following, substituting your desired sheet name accordingly:
Code:
Sub temp()
'
' temp Macro
'

'
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("R075").Select
End Sub
Hope this helps,
Cindy
 

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,484
Cindy,

You are EXACTLY right; Thanks for "interpreting" what I was unable to cleary say;
Your Code now incorporated into my other code - it doing exactly what I wanted.

Tks,

Jim
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,613
Messages
5,832,710
Members
430,155
Latest member
spacedad41

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
Top