Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Stop the loop after it runs for 10 times.

Hi,

I want to run the below mentioned loop for only 10 times.
Does anyone know how to stop the loop after it complete 10 rounds.

Sub LOOP12()

Do Until ActiveCell.Value = ""

If ActiveCell.Value = 10 Then

ActiveCell.Offset(0, 1).Value = 15

End If

ActiveCell.Offset(1, 0).Select

Loop

End Sub

Regards
Heera
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Stop the loop after it runs for 10 times.


sub loop12()'NO selections
mc=activecell.column
for i= 1 to 10
if cells(i,mc)=10 then cells(i,mc+1)=15
next i
end sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Heera" wrote in message
...
Hi,

I want to run the below mentioned loop for only 10 times.
Does anyone know how to stop the loop after it complete 10 rounds.

Sub LOOP12()

Do Until ActiveCell.Value = ""

If ActiveCell.Value = 10 Then

ActiveCell.Offset(0, 1).Value = 15

End If

ActiveCell.Offset(1, 0).Select

Loop

End Sub

Regards
Heera


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Stop the loop after it runs for 10 times.

Sub LOOP12()
i = 1
Do Until ActiveCell.Value = ""
If i = 10 Then Exit Do
i = i + 1
If ActiveCell.Value = 10 Then
ActiveCell.Offset(0, 1).Value = 15
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub

--
Gary''s Student - gsnu2007k
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Stop the loop after it runs for 10 times.

Hi, here is my take:
1) IF "loop for 10 times" means that 10 times of value=10,
put iX = iX + 1 inside the IF...THEN

Sub LOOP12A()
Dim iX as integer ' count how many times
iX=0

Do Until ActiveCell.Value = "" or iX=10
If ActiveCell.Value = 10 Then
ActiveCell.Offset(0, 1).Value = 15
End If
iX=iX+1
ActiveCell.Offset(1, 0).Select
Loop

End Sub

--AC

"Don Guillett" wrote:


sub loop12()'NO selections
mc=activecell.column
for i= 1 to 10
if cells(i,mc)=10 then cells(i,mc+1)=15
next i
end sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Heera" wrote in message
...
Hi,

I want to run the below mentioned loop for only 10 times.
Does anyone know how to stop the loop after it complete 10 rounds.

Sub LOOP12()

Do Until ActiveCell.Value = ""

If ActiveCell.Value = 10 Then

ActiveCell.Offset(0, 1).Value = 15

End If

ActiveCell.Offset(1, 0).Select

Loop

End Sub

Regards
Heera



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
How to stop other macros while current macro runs Paul987[_23_] Excel Programming 2 April 24th 06 05:15 PM
Can you code a macro so it runs multiple times in the same workboo dpmac Excel Discussion (Misc queries) 2 April 18th 06 07:40 PM
ADO command.execute with a loop - only runs once George King Excel Programming 0 February 9th 06 06:24 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 04:48 AM.

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

About Us

"It's about Microsoft Excel"