Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default code loops 1024 times not what i ask

Hi

I wonder if someone can help, I am trying to repeat some code 200 times can
you tell me where I am going wrong in my loop.

(It is doing 1024 times!)

Sub test()
Dim x As Integer

Do Until x = 200
'code to repeat
x = x + 1
Loop

End Sub

thanks for your help.

Rob



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default code loops 1024 times not what i ask

Hi Rob,

Your code works for me.

To test it, I changed:

x = x + 1

to

x = x + 1
Debug.Print x

What final value do you get in the intermediate window if you add the debug
line?

---
Regards,
Norman



"Rob Hargreaves" wrote in message
...
Hi

I wonder if someone can help, I am trying to repeat some code 200 times
can you tell me where I am going wrong in my loop.

(It is doing 1024 times!)

Sub test()
Dim x As Integer

Do Until x = 200
'code to repeat
x = x + 1
Loop

End Sub

thanks for your help.

Rob




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default code loops 1024 times not what i ask

Try it like this

Sub test()
Dim x As Integer
x = 0
Do Until x = 200
'code to repeat
x = x + 1
Loop
MsgBox x
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Rob Hargreaves" wrote in message ...
Hi

I wonder if someone can help, I am trying to repeat some code 200 times can you tell me where I am going wrong in my loop.

(It is doing 1024 times!)

Sub test()
Dim x As Integer

Do Until x = 200
'code to repeat
x = x + 1
Loop

End Sub

thanks for your help.

Rob




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default code loops 1024 times not what i ask

Hi thanks for your responses guys.

I have tried to add the msgbox and it does display the correct number.

The code i am using selects all then copies the selection and I was
including this in my loop!

Now moved it works as it should.

Thanks again

Rob



"Rob Hargreaves" wrote in message
...
Hi

I wonder if someone can help, I am trying to repeat some code 200 times
can you tell me where I am going wrong in my loop.

(It is doing 1024 times!)

Sub test()
Dim x As Integer

Do Until x = 200
'code to repeat
x = x + 1
Loop

End Sub

thanks for your help.

Rob






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
ADO & Loops: error in code? Santiago[_2_] Excel Programming 2 July 28th 05 07:25 PM
Help on writing code more efficiently (Loops) Kathryn[_5_] Excel Programming 3 May 25th 04 08:45 PM
Code works but I have to run it 4 times Todd Huttenstine Excel Programming 4 May 10th 04 08:47 PM
Help with text box limit (1024) irais Excel Programming 2 November 28th 03 04:18 PM
Over-Eager code is pasting 3 times Stuart[_5_] Excel Programming 3 September 10th 03 07:30 PM


All times are GMT +1. The time now is 08:57 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"