Use a single cell's value to create and name multiple new worksheets

Gl3n

New Member
Joined
Jan 7, 2022
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hello! Hoping someone can help with this, I'm sure it's something simple but I'm lost...

I have the below code which will create a number of new worksheets based off the numerical value in cell G28, this part is working fine.
What I'd like it to do next is to name each worksheet "Connector 1", "Connector 2", etc until all worksheets are named up to the value in G28.

I've commented out where I started playing around to see what happened (I didn't get far) and I understand that second part of the 'sheet_name' string wont work (it counts down rows from G28 and names the sheets with the values found in those cells).

Sub AddConnectorSheets()

Dim sheets_count As Integer
Dim sheet_name As String
'Dim sheet_number As Integer
Dim i As Integer

sheet_count = Sheets("Home").Range("G28").value
'sheet_number = Sheets("Home").Range("G28").value

For i = 1 To sheet_count
'sheet_name = "Connector " & sheet_number
sheet_name = "Connector " & Sheets("Home").Range("G28").Cells(i, 1).value
Worksheets.Add(After:=Sheets(Sheets.Count)).Name = sheet_name


Next i

End Sub


Thanks for reading!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi & welcome to MrExcel.
How about
VBA Code:
Worksheets.Add(After:=Sheets(Sheets.Count)).Name = "Connector " & i
 
Upvote 0
Solution
Hi & welcome to MrExcel.
How about
VBA Code:
Worksheets.Add(After:=Sheets(Sheets.Count)).Name = "Connector " & i
Thanks for the warm welcome and the super quick reply!
Yes, that's worked perfectly, thanks Fluff!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,065
Messages
6,122,945
Members
449,095
Latest member
nmaske

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