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.
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.
This is what you can use:Then, for real use, you can valorize a variable instead of the Debug.Print and add a MsgBox if there is no previous sheet.![]()
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
Last edited by rollis13; 02-13-2023 at 06:46 AM.
10x but I want to use it in a formula.
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.
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),"")
10x to all!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks