Stop the loop after it runs for 10 times.

H

Heera

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
 
D

Don Guillett

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
 
G

Gary''s Student

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
 
A

AndrewCerritos

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
 

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

Similar Threads

Macro is not able to identify the value. 3
Need help-For loop 3
Do Until or For Loop 3
Do Until Loop Not Working 1
PLEASE help ... 3
Do Until Loop Not Working 3
Speed it up? 4
fill range 4

Top