ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Do Loop doesn't process (https://www.excelbanter.com/excel-programming/310594-do-loop-doesnt-process.html)

kls[_2_]

Do Loop doesn't process
 
I am using the top sub to control detection of the first row that has a
nonnull value in ColG. If I select any cell on the sheet other than G2
and then run the sub, a message box appears as expected and G2 is
highlighted. Using F8 fxn key, each subsequent row is highlighted
through "Do While Not IsEmpty(ActiveCell)", but then jumps down to End
Sub. Neither "Range" or the value for Count appears in the intermediate
window. What am I doing wrong (I have copied this from other
applications I have developed which work fine)?

Thanks

Sub Control()

Range("G2").Select
MsgBox ActiveCell.Value


Count = 0
'Debug.Print Count
CountRows

End Sub
__________________________________


Option Explicit
Public Count As Integer

Public Sub CountRows()
Do While Not IsEmpty(ActiveCell)
Debug.Print "Range"

ActiveCell.Offset(1, 0).Select
Count = Count + 1
Debug.Print Count
Loop

End Sub


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 05:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com