Is there Existing code for such?

jim may

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

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Fowmy

Well-known Member
Joined
Jul 10, 2008
Messages
512
Office Version
365
Platform
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
75,766
Office Version
365
Platform
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,471

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
75,766
Office Version
365
Platform
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,471
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
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,805
Messages
5,513,512
Members
408,955
Latest member
BodanKaraoke

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top