+ Reply to Thread
Results 1 to 2 of 2

Count # of rows

  1. #1
    Registered User
    Join Date
    02-25-2005
    Posts
    4

    Count # of rows

    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.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1