Looping macro a certain number of times?

spiffmonkey1

New Member
Joined
Jun 23, 2011
Messages
41
Hi, i have a macro-
Sub Changecolor()
Dim r as Long
FinalColumn = Application.WorksheetFunction.CountA(Range("D70:AIU70"))
For r = 4 To FinalColumn + 3
If WorksheetFunction.CountIf(Range(Cells(72, r), Cells(83, r)), "yes") = 1 _
And WorksheetFunction.CountIf(Range(Cells(72, r), Cells(83, r)), "N/A") = 8 _
And WorksheetFunction.CountBlank(Range(Cells(72, r), Cells(83, r))) = 3 Then
Range(Cells(70, r), Cells(70, r)).Interior.ColorIndex = 50
Range(Cells(70, r), Cells(70, r)).Font.ColorIndex = 1
Range(Cells(70, r), Cells(70, r)) = "Red" 'Text in the cell
Range(Cells(70, r), Cells(70, r)).BorderAround Weight:=xlThick
End if
next r
End Sub

I want to know if it is possible to loop this macro like a hundred times or if i can make it loop and then stop if the cell text count is the same.

Thanks
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
add a

Code:
for x = 1 to 100
 
YOUR CODE HERE
<YOUR code>
 
 If then test, if true then goto jumpout:
next x
 
jumpout:
end sub
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,735
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top