I am writing a macro to iterate over some entries and would like for a loop to avoid any possibility of an infinite loop, for example:
For i = 0 to COUNT **do stuff with START_CELL.Offset(i,0) Next
I donโt remember how to make calculations from VBA, so the search sent me here: Use VBA to count non-empty cells in a column . One suggestion was
n = Worksheets("Sheet1").Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
It seemed more complicated, so I did a few more digging and decided that I would use:
COUNT = Application.WorksheetFunction.Count(COUNT_RANGE)
Another example on this page uses Application.WorksheetFunction.CountA() , but still bothers me (paranoid) now, so I should avoid it. Whether there is a?
Thanks to everyone.
source share