I am writing a macro to iterate over some records and wanted to a for-loop to avoid any chance of infinite while looping like:
For i = 0 to COUNT
**do stuff with START_CELL.Offset(i,0)
Next
I couldn't remember how to do a count of things from VBA so a search sent me here: Use VBA to Count Non Blank Cells in a Column. One suggestion was
n = Worksheets("Sheet1").Range("A:A").Cells.SpecialCells(xlCellTypeConstants).Count
This seemed over complicated, so I did some more digging and decided I was going to use:
COUNT = Application.WorksheetFunction.Count(COUNT_RANGE)
Another example on that page used Application.WorksheetFunction.CountA()
, but still now I am concerned (paranoid) there is a reason I should avoid it. Are there any?
Thanks all.