+ Reply to Thread
Results 1 to 6 of 6

Counting number of rows (with skips)

Hybrid View

MasterMonk Counting number of rows (with... 06-04-2007, 02:51 PM
VBA Noob How about NumRows =... 06-04-2007, 03:00 PM
MasterMonk That works, but that means I... 06-04-2007, 03:22 PM
royUK My code counts the blanks in... 06-04-2007, 03:35 PM
MasterMonk Oh really! That's great,... 06-04-2007, 04:11 PM
royUK Like this Dim rng As... 06-04-2007, 03:04 PM
  1. #1
    Registered User
    Join Date
    04-18-2007
    Posts
    47

    Counting number of rows (with skips)

    Hi

    I have a large sheet, "Sheet1" that is dynamic. I want to count the number of rows, however there are sometimes single empty rows in between my rows. Is there an elegant way to count the number of rows in the sheet?

    NumberofRows = Worksheets("Sheet1").Range("A1").End(xlDown).Row
    I've used the above but it will count until the break in the worksheet and not continue. Help please!

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    How about

    NumRows = Application.WorksheetFunction.CountA(Range("A:A"))
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    04-18-2007
    Posts
    47
    Quote Originally Posted by VBA Noob
    How about

    NumRows = Application.WorksheetFunction.CountA(Range("A:A"))
    VBA Noob
    That works, but that means I will search EVERY cell right? A little inefficient? My next job in the line is a:

     Do While x < NumRows
    "execute x command"
    loop
    If I just select ALL rows and I run a bunch of these, it will bog down the system. Are there any other suggestions?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    My code counts the blanks in ColumnA used cells.

    It wouldn't hurt to thank helpers for their assistance!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    04-18-2007
    Posts
    47
    Oh really!

    That's great, thanks a lot, I will try that out.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Like this

    Dim rng As Range
    Dim NumRows As Long
    
    Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
    
    NumRows = Application.WorksheetFunction.CountA(rng)

+ 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