Add worksheets and name them from data in an array?

TheWennerWoman

Board Regular
Joined
Aug 1, 2019
Messages
110
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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,877
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Dim i As Long
For i = LBound(c) To UBound(c)
   Sheets.Add.Name = c(i)
Next i
 

TheWennerWoman

Board Regular
Joined
Aug 1, 2019
Messages
110
Office Version
  1. 365
Platform
  1. Windows
Thank you for that.

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

highlighted?
 

TheWennerWoman

Board Regular
Joined
Aug 1, 2019
Messages
110
Office Version
  1. 365
Platform
  1. Windows
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!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,877
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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
 
Solution

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,877
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,148,007
Messages
5,744,319
Members
423,861
Latest member
Ka3EeM

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
Top