Copying sheet tab "x" number of times

J

JDaywalt

I have a sheet tab that is named "MASTER". I am trying to write a macro that
will copy this sheet tab multiple times based upon the value in cell A1 of a
sheet tab called "QTY". For example, if the value on the QTY tab is "4", the
"MASTER" tab will be copied 4 times---always placing the new tab at the "end"
of the sheet tab block. Can someone help with this?
 
D

Dale Fye

Since I'm relatively new to the Excel object model, I usually start out by
creating a macro to do what I want (in this case, copy the Master worksheet
to the end of the workbook). Then I'll add the code I need around that.
Something like:

Public Sub CopySheet

Dim intLoop as integer

intLoop = 1
Do While intLoop <= ActiveWorkbook.Sheets("SheetName").Cells("A1")

'put your copy code in here
'you might want to add some code that changes the names of the
'copy by appending the intLoop value to the word "Copy"

intLoop = intLoop + 1
Loop

End Sub

HTH
Dale
 
D

Don Guillett

Sub addshts()
For i = 1 To InputBox("Enter sheets desired") - 1
Sheets("Master").Copy After:=Sheets("Master")
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top