![]() |
VBA Loop
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? |
VBA Loop
x=10 For i = 1 to x 'your copy code Next x -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=135035 |
VBA Loop
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 On Sep 15, 4:09*pm, ASteele wrote: 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? |
VBA Loop
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 On Tue, 15 Sep 2009 13:09:01 -0700, ASteele wrote: 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? |
All times are GMT +1. The time now is 06:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com