Add worksheets loop

ojhawkins

New Member
Joined
Nov 17, 2011
Messages
39
Hi all,

I am trying to create a loop to add multiple worksheets

I want to add a new sheet for each company (A2:A14)

This is what I have so far, not sure how far off I am. Can anyone help?
I am also wanting to add the sheets after the current last sheet if possible.

Sub addnewsheet()

x = 2
Do Until Cells(x, 1) <> ""

Sheets.Add.Name = Worksheets("securities").Cells(x, 1).Value & ".ax"

x = x + 1

Loop

End Sub

103a1as.png
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
You're close.. but try
Code:
Sub addnewsheet()
x = 2
Do Until [B][COLOR=Red]Worksheets("securities")[/COLOR].[/B]Cells(x, 1) [COLOR=Red][B]=[/B][/COLOR] ""
    Sheets.Add.Name = Worksheets("securities").Cells(x, 1).Value & ".ax"
    x = x + 1
Loop
End Sub
 
Upvote 0
edit***

I have this below.

Just need to work out the loop

x = 2

Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = Worksheets("securities").Cells(x, 1).Value & ".AX"
 
Upvote 0

Forum statistics

Threads
1,223,244
Messages
6,170,976
Members
452,372
Latest member
Natalie18

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