+ Reply to Thread
Results 1 to 6 of 6

Previous Sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    02-13-2023
    Location
    Timișoara
    MS-Off Ver
    2016
    Posts
    3

    Question Previous Sheet

    Hello.
    How can I find out the name of the previous sheet (from the left) if all the sheets have been renamed and no longer have their original names Sheet1, Sheet2, ...
    Thanks.

  2. #2
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    935

    Re: Previous Sheet

    This is what you can use:
    Option Explicit
    Sub PreviousSheetName()
        If ActiveSheet.Name <> Sheets(1).Name Then    'checks if it isn't the first sheet (avoids the error message)
            Debug.Print ActiveSheet.Previous.Name     'print name in Immediate panel of VBE
        End If
    End Sub
    Then, for real use, you can valorize a variable instead of the Debug.Print and add a MsgBox if there is no previous sheet.
    Last edited by rollis13; 02-13-2023 at 06:46 AM.

  3. #3
    Registered User
    Join Date
    02-13-2023
    Location
    Timișoara
    MS-Off Ver
    2016
    Posts
    3

    Re: Previous Sheet

    10x but I want to use it in a formula.

  4. #4
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    935

    Re: Previous Sheet

    Sorry, no idea how this can be done with a simple formula; for sure needs at least an UDF.
    Try googling "previous sheet formula excel".
    Last edited by rollis13; 02-13-2023 at 11:57 AM.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Previous Sheet

    Add a named range, via Name Manager, called Sheetnames
    =REPLACE(GET.WORKBOOK(1),1,FIND("]",GET.WORKBOOK(1)),"")


    The depending on excel version either of these formula.

    =IFERROR(INDEX(SHEETNAMES,1,MATCH(TEXTAFTER(CELL("Filename",$A$1),"]"), SHEETNAMES,0)-1),"")
    =IFERROR(INDEX(SHEETNAMES,1,MATCH(MID(CELL("Filename",$A$1),FIND("]",CELL("Filename",$A$1))+1,LEN(CELL("Filename",$A$1))), SHEETNAMES,0)-1),"")
    Cheers
    Andy
    www.andypope.info

  6. #6
    Registered User
    Join Date
    02-13-2023
    Location
    Timișoara
    MS-Off Ver
    2016
    Posts
    3

    Re: Previous Sheet

    10x to all!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] select next sheet based on ending of month for year for previous sheet
    By abdo M in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 01-17-2023, 03:29 PM
  2. Replies: 8
    Last Post: 03-27-2020, 11:39 AM
  3. Autofilter, copy from sheet 1 and paste to sheet2, delete previous info on sheet 2
    By leigh12483 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-30-2015, 08:21 PM
  4. Copy Cell Range From Previous Sheet and Paste to Active Sheet
    By jtal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2013, 03:26 PM
  5. Macro to add sheet, name it based on previous sheet, and delete a range of cells
    By Moeshell in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-24-2011, 03:26 PM
  6. Replies: 4
    Last Post: 03-22-2011, 09:44 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1