How to add sheet

bhandari

Active Member
Joined
Oct 17, 2017
Messages
359
if A1=1 then add one sheet
and change the Sheet name Pkg 1
if A1=2 then add 2 sheet
and change the name "1st Sheet"Pkg 1,"2nd Sheet " Name:Pkg 2
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
I have data in B1:G30
it is fixed format for A4 size
can it copy as it is in Pkg 1,Pkg 2...etc
 
Upvote 0
Code:
Sub test()
For i = 1 To Range("A1").Value
With Worksheets.Add
    .Name = "Pkg " & i
End With
With Sheets("Pkg " & i)
    .Range("B1:G30").Value = Range("B1:G30").Value
End With
Next i
End Sub
 
Upvote 0
I forgot to place the sheets in the right order:

Code:
Sub test()
For i = 1 To Range("A1").Value
With Worksheets.Add(After:=Worksheets(Worksheets.Count))
    .Name = "Pkg " & i
End With
With Sheets("Pkg " & i)
    .Range("B1:G30").Value = Range("B1:G30").Value
End With
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,495
Messages
6,113,992
Members
448,538
Latest member
alex78

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