I am a newbie, and need to use the count of rows for conditional looping. I would like to know how can i get the count.
when i use the count "LastRow = Cells(Rows.Count, "A").End(xlUp).Row"
, i get error object required"Rows". how can i set that.
I am a newbie, and need to use the count of rows for conditional looping. I would like to know how can i get the count.
when i use the count "LastRow = Cells(Rows.Count, "A").End(xlUp).Row"
, i get error object required"Rows". how can i set that.
Hello Sachinmk,
Change you code a little to ensure the Range is qualified. You're original code is below.
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Make the following changes so the Range Object is qualified. Also, your code is more flexible with the RowCount now as variable. You can use later in the loop if you need it without the overhead of Excel recalculating it.
RC = Range("A:A").Rows.Count
LastRow = Cells(RC, "A").End(xlUp).Row
The golden rule of VBA programming: Qualify your objects.
VBA doesn't allow much slop in the code. So, develop good programming practices early, and you will have more fun coding than frustration debugging.
Have fun,
Leith Ross
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks