Prompt for tab name and then prompt for number of iterations of ta

B

bert_lady

Need code to prompt users for the name of the sheet to copy and then prompt
for the number of copies of the sheet they want. I have dinked around with
this for a while and am really missing something

Thanks
 
M

Matthew Herbert

bert_lady,

Utilize the help documentation. Search "InputBox" and read the
documentation on Application.InputBox Method and InputBox Function. Also,
search "Worksheets.Add" and read the documentation for Worksheets.Add Method.
After you prompt the user for the worksheet name, you should validate that
the worksheet exists before prompting for the number of copies.

Start with the help documentation. If you are still having trouble, post
your code to the thread with any subsequent questions.

Best,

Matthew Herbert
 
G

Gord Dibben

Sub SheetCopy22()
Dim I As Long
Dim shts As Long
Dim whichone As String
On Error GoTo endit
Application.ScreenUpdating = False
whichone = InputBox("enter sheet name to copy")
shts = InputBox("How many times?")
For I = 1 To shts
Sheets(whichone).Copy After:=ActiveSheet
' With ActiveSheet
' .Name = "NewSheet" & I
' End With
Next I
Application.ScreenUpdating = True
endit:
End Sub


Gord Dibben MS Excel MVP
 

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