I am currently using a piece of VBA code to auto-populate blank cells in column C of my report. The only thing is it will autopopulate past the end of my data set. (There are several columns of data in this report.) In order to stop the VBA code, I have set the range up to C1500. I would prefer it if that macro would just automatically stop once it reached rows with no data in them. Does any one know how to change my code to accomplish this?
Sub Macro1()
mynumber = 1
Dim r As Range, cell As Range
Set r = Range(Range("C2"), Range("C1500"))
For Each cell In r
If cell.Value = OK Then cell.Value = mynumber
mynumber = mynumber + 1
Next
End Sub