Add worksheets and name them from data in an array?

TheWennerWoman

Active Member
Joined
Aug 1, 2019
Messages
270
Office Version
  1. 365
Platform
  1. Windows
Thanks to very kind members of this forum, I have an array populated with values from a range of cells
Code:
Dim c as Variant
With Range("AK3", Range("AK" & Rows.Count).End(xlUp))
    c = Evaluate(Replace("unique(filter(#, # <> """"))", "#", .Address))
End With

I now need to create new worksheets which I want named using values in the array.....and I've got stuck.

I got as far as
Code:
d = UBound(c) - LBound(c) + 1
For e = 1 To d
Sheets.Add.Name = ????

How do I extract the values from the array? Or is my approach all wrong?

Thank you in advance.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
How about
VBA Code:
Dim i As Long
For i = LBound(c) To UBound(c)
   Sheets.Add.Name = c(i)
Next i
 
Upvote 0
Thank you for that.

Subscript out of range error with
Code:
Sheets.Add.Name = c(i)

highlighted?
 
Upvote 0
Solved it
Code:
For e = LBound(c) To UBound(c)
    For f = LBound(c, 2) To UBound(c, 2)
    Sheets.Add.Name = c(e, f)
    Next f
Next e

Thank you Fluff for pointing me in the right direction!
 
Upvote 0
You don't need that inner loop, my code should have been
VBA Code:
Dim i As Long
For i = LBound(c) To UBound(c)
   Sheets.Add.Name = c(i, 1)
Next i
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,615
Messages
6,120,538
Members
448,970
Latest member
kennimack

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