Is there Existing code for such?

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this macro

Code:
Sub ActSht()
  Sh = InputBox("Enter Sheet name")
  (Sh).Move Before:=Sheets(1)
End Sub
 
Upvote 0
Try this in the ThisWorkbook module


Code:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Me.Move before:=Sheets(1)
End Sub
 
Upvote 0
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.
 
Upvote 0
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)????
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

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
Back
Top