VBA Loop

A

ASteele

I need to run a copy code an "x" number of times. The value for "x" is
variable and I would like to declare it within the code for the copy routine.

What is the easiest way for a beginner, like me, to write the code?
 
J

JP

First you need to understand your goal and determine if a loop is the
best way to accomplish it. If so, then you need to decide what type of
loop to use. There are several types of loops, but unless you disclose
how 'x' is calculated, it would be difficult to suggest the
appropriate type.

--JP
 
G

Gord Dibben

Example code............

Sub SheetCopy()
Dim x As Long
Application.ScreenUpdating = False
shts = InputBox("How many times")
For x = 1 To shts
ActiveSheet.Copy After:=ActiveSheet
Next x
Application.ScreenUpdating = True
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