How to copy a subset of data from a dynamic list?

kungfugecko

New Member
Joined
Dec 15, 2021
Messages
3
Office Version
  1. 2013
I have a workbook with multiple sheets, such as this:

1639546975897.png


and I am using a VBA code to create a dynamic index page which will list all new sheets added:

1639547020494.png

The 'First' and 'Last' sheets will always be present in this workbook, and all new sheets will be placed between these sheets. Is there a formula to create a list of all values (names in this case) that are present between 'First' and 'Last' on this dynamic list? so I would like to have a formula to output a list of just:

Abby Alkatraz
Billy Bob
Crazy Chris

Thanks in advance
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Welcome to the MrExcel board!

Suppose you wanted the list on the 'Index' sheet in column A starting at row 2, you could try this.

VBA Code:
Sub ListSheets()
  Dim i As Long, k As Long
  
  For i = Sheets("First").Index + 1 To Sheets("Last").Index - 1
    Sheets("Index").Range("A2").Offset(k).Value = Sheets(i).Name
    k = k + 1
  Next i
End Sub
 
Upvote 0
Solution
Welcome to the MrExcel board!

Suppose you wanted the list on the 'Index' sheet in column A starting at row 2, you could try this.

VBA Code:
Sub ListSheets()
  Dim i As Long, k As Long
 
  For i = Sheets("First").Index + 1 To Sheets("Last").Index - 1
    Sheets("Index").Range("A2").Offset(k).Value = Sheets(i).Name
    k = k + 1
  Next i
End Sub
Thank you so much for the help! I tried your solution but I think I am just not implementing it properly. I have applied this code to my subindex work sheet, but there is no output on the sheet, even after saving and Refresh All.

1639579444336.png
 
Upvote 0
Welcome to the MrExcel board!

Suppose you wanted the list on the 'Index' sheet in column A starting at row 2, you could try this.

VBA Code:
Sub ListSheets()
  Dim i As Long, k As Long
 
  For i = Sheets("First").Index + 1 To Sheets("Last").Index - 1
    Sheets("Index").Range("A2").Offset(k).Value = Sheets(i).Name
    k = k + 1
  Next i
End Sub
I apologize I'm not sure how to edit my previous comment, but I wanted to let you know I did get it figured out, your solution worked brilliantly. Thank you!!!
 
Upvote 0
You're welcome. Glad you got it resolved. Thanks for letting us know. :)
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,391
Members
449,080
Latest member
Armadillos

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