Worksheets.Add

XLML

Active Member
Joined
Aug 15, 2003
Messages
407
How can Worksheets.Add in vba be modified to insert a worksheet to the Right and not Left of the Active Sheet?

Thanks in advance,
XLML
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Thanks pgc01. I am having problems because I am attempting to add the last sheet of a workbook.


XLML
 
Upvote 0
if you mean adding sheet to the right of the last sheet then;
Code:
Worksheets.Add after:=Sheets(Sheets.Count)
 
Upvote 0
XLML

agihcam's solution is better. Sheets includes both worksheets and chart sheets. This assures that the new worksheet is the last sheet in the workbook.

Cheers
PGC
 
Upvote 0
I've been looking for something kinda like this.


All my sheets are numbered and in numerical order going from 1 to infinite.

I'm copying the master sheet "Master", and the new sheet would go to the end, named as the next available number..

If "3" is the last, the next would be "4" and so on....

Anyone?
 
Upvote 0
Hi DKcrm

I'm not sure I understood well.

This is what I understood:

You start with a workbook with one worksheet named "Master"

You now want to make copies of the worksheet "Master", that go to the end and have the names "1", "2", "3", ...

If this is the case, try:

Code:
Worksheets("Master").Copy after:=Sheets(Sheets.Count)

If Worksheets(Worksheets.Count - 1).Name = "Master" Then
    Worksheets(Worksheets.Count).Name = 1
Else
    Worksheets(Worksheets.Count).Name = Worksheets(Worksheets.Count - 1).Name + 1
End If

Hope this helps
PGC
 
Upvote 0
pgc01>>

This was exactly what I was looking for. It works perfectly. Thank you :)

Using this gives me a copy of the master. Now, I need to make some changes in every worksheet with a number.

What should I do to alter the code so it is possible to copy the worksheet I'm in (random) and put the copy in the end?
 
Upvote 0

Forum statistics

Threads
1,226,217
Messages
6,189,687
Members
453,563
Latest member
Aswathimsanil

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