Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50165

Setting Loop to the smallest number needed

$
0
0
Thus far, when I want to loop something I just set the loop to be greater than what I need it to be.

Code:

For i = 1 to 5000

if cells(i,1).value=5 then
cells(i,1).interior.color = 1
end if

next

But then I have to wait while the macro checks alot of empty cells below where I have the data. I know I could use

Code:

Do while activecell.value<> empty
loop

But could I do something similar to this??

Code:

For i = 1 to Columns("A").count

Next


Viewing all articles
Browse latest Browse all 50165

Trending Articles