#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default 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?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
returning back to loop check condition without completing the loop ashish128 Excel Programming 13 April 3rd 08 12:53 PM
Loop to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Excel Programming 3 February 5th 08 03:41 PM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 0 March 27th 07 11:17 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM


All times are GMT +1. The time now is 06:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"