Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

copying same tab several

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Copying same tab several times and changing just one cell

Copying same tab several times and changing just one cell

ResolvedVersion 2010

Katherine has attended:
Excel Advanced course
Excel VBA Intro Intermediate course

Copying same tab several times and changing just one cell

I have got a worksheet set up which has one cell (made up of a 4 digit code) that can be changed. I need to be able to replicate the same worksheet for upto 100 other 4 digit codes which I have placed into a list on another worksheet within the same workbook.

Ideally, the VBA will also rename the worksheets so that it is the same as the 4 digit code.

Would this be possible to do with a VBA?

Many thanks,
Katherine

RE: Copying same tab several times and changing just one cell

Hi Katherine, thanks for your query. It certainly is possible! You will need to loop through that list, dropping each cell value into a value and then using:

Sheets.Add
Activesheet.name = thecode

The result will be a lot of new worksheets named after your 4 digit code!

Hope this helps,

Anthony

RE: Copying same tab several times and changing just one cell

Thank you for the response. I found the code below which allowed me to copy, then using the knowledge learned in the class and your response I managed to tweak it to work.

Thanks,
Katherine



Sub Copier2()
Dim x As Integer

x = InputBox("Enter number of times to copy Sheet1")
For numtimes = 1 To x
'Loop by using x as the index number to make x number copies.
'Replace "Sheet1" with the name of the sheet to be copied.
ActiveWorkbook.Sheets("Sheet1").Copy _
After:=ActiveWorkbook.Sheets("Sheet1")
Next
End Sub

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Showing all menu items

If you go into a pull down menu you usally find that you get a selection of items(this is the default) or sometimes everything. If you only get a selectiopn you have to go to the double arrows at the bottom of the menu and click it to get all of the hidden items.
To turn this off so that you always get everything, go to Tools / Customize / Options Tab / "Always show full menus". Make sure there is a tick in the box and you will always have every item.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.12 secs.