Worksheet Names in cells

mniedert

Board Regular
Joined
Apr 13, 2005
Messages
72
I want to create a Validation list which uses all of the Worksheet names in my spreadsheet. So for example, if I have 12 worksheets I would have the 12 worksheet names listed in order from A1 to A12. Is there a formula that would allow me to do that?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I want to create a Validation list which uses all of the Worksheet names in my spreadsheet. So for example, if I have 12 worksheets I would have the 12 worksheet names listed in order from A1 to A12. Is there a formula that would allow me to do that?

you can with VBA

you will need to paste the following code into the "thisworkbook" module of your workbook.

steps to do this

1. press ALT+F11 (this will take you to the VBE window
2. Double click the 'ThisWorkBook' module (upper left window section will have a list under 'Microsoft Excel Objects' it will be the last one in the list)
3. Paste the code
4. save

This should do the trick.


Code:
Private Sub Workbook_Open()
Dim wsLIST As Worksheet, ws As Worksheet
Dim i As Integer
Dim lngROW As Long
    Set wsLIST = Sheets("Sheet1") '****Change the name in quotes to suit your needs
    wsLIST.Select
    With wsLIST
        lngROW = Range("A" & .ROWS.Count).End(xlUp).Row
        Range(.Cells(1, 1), .Cells(lngROW, 1)).ClearContents
        i = 1
        For Each ws In Worksheets
            Range("A" & i).Value = ws.Name
            i = i + 1
        Next ws
    End With
End Sub

One change on your end...

Change this line so that the name of the sheet inside the quotes reflects the name of the worksheet you want the list to be on

Code:
Set wsLIST = Sheets("Sheet1") '****Change the name in quotes to suit your needs
 
Last edited:
Upvote 0
Here's another way by using a new tab (worksheet) for the list:


  1. In Formulas | Name Manager create a new name (SheetNames) and assign it this value: =GET.WORKBOOK(1)&T(NOW())
  2. In the first cell where you want your list to appear, type this: =IFERROR(INDEX(MID(SheetNames,FIND("]",SheetNames)+1,255),ROWS(A$1:A1)),"")
  3. Drag down as far as you need to.
  4. You can now use this as the source for your validation list. The workbook needs to be saved as macro-enabled.
 
Upvote 0
Here's another way by using a new tab (worksheet) for the list:


  1. In Formulas | Name Manager create a new name (SheetNames) and assign it this value: =GET.WORKBOOK(1)&T(NOW())
  2. In the first cell where you want your list to appear, type this: =IFERROR(INDEX(MID(SheetNames,FIND("]",SheetNames)+1,255),ROWS(A$1:A1)),"")
  3. Drag down as far as you need to.
  4. You can now use this as the source for your validation list. The workbook needs to be saved as macro-enabled.

I really like this.

Learn something new everyday.

The OP just needs to decide if this is a list they want to maintain or have it dynamically maintained each time the work book opens.
 
Upvote 0

Forum statistics

Threads
1,216,309
Messages
6,130,004
Members
449,552
Latest member
8073662045

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