VBA Code to Create Individually Named Tabs

tbwalter

New Member
Joined
Sep 8, 2021
Messages
9
Office Version
  1. 365
Platform
  1. Windows
I've been struggling with this idea for a while. I want to take the below table and add a button that results in individually named tabs. In the example below, after hitting the "Generate Tabs" button, there would be 5 new tabs: Site A-1, Site A-2, Site A-3, Site B-1, and Site C-1. The site names would be variables, and blanks would be treated as zeros. Any help you could provide would be greatly appreciated.

Colocation Order Form Content.xlsm
ABCDEFGH
16Site #LocationHalfFullCage
171Site A120
182Site B001
193Site C100
204
215
226
237
248Generate Tabs
259
2610
27
Start Here
 
So what if instead of using a "named range", I used a sheet name/cell name? In this case, it would be Sheet Name: Cabinet, Cells: A1:G98. I thought that using a named range would be easier, but I guess not. I can delete the range name without issue. Would that be easier?
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hi.
Ok, so your named range you are wanting to copy, is it just the values from the named range you want to put into the new sheet.

if so, using the named range should be fine.

but I cannot quite understand what you require.

Is this code part of the code I previously wrote for you. And you want the named range values in each new worksheet.
Or
Is this a bee code where you want to add 1new sheet with the named range values in it ?
 
Upvote 0
This would be an addition to the code you wrote. I was hoping to just add a copy line, but apparently I'm not enough on the ball. I really appreciate your help here. Again, it doesn't have to be a named range. I just created a template on one tab (Sheet Name: Cabinet, Cells: A1:G98), and want it copied when the new tabs are created.
 
Upvote 0
You you want a code that does the following.

1. Creates a new tab.
2. Copies your range to the new tab.



Dave
 
Upvote 0
I got it! I added: ThisWorkbook.Sheets("Cabinet").Range("A1:G100").EntireRow.Copy ActiveSheet.Range("A1") to your code, and it works like a charm. The final code is:

Sub add_tabs()

' This code was written by SQUIDD @ MREXCEL.COM

Application.ScreenUpdating = False
STARTSHEET = ActiveSheet.Name
LR = Range("B" & Rows.Count).End(xlUp).Row
For A = 17 To LR
Sheets(STARTSHEET).Activate
Total = Application.WorksheetFunction.Sum(Range("C" & A & ":E" & A))
For B = 1 To Total
Sheets(STARTSHEET).Activate
Sheets.Add.Name = Range("B" & A) & "-" & B
ThisWorkbook.Sheets("Cabinet").Range("A1:G100").EntireRow.Copy ActiveSheet.Range("A1")
Next B
Next A
Sheets(STARTSHEET).Activate
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Well done, im glad you sorted that out, and its nice feeling when you work it out yourself.
 
Upvote 0

Forum statistics

Threads
1,216,178
Messages
6,129,325
Members
449,501
Latest member
Amriddin

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