+ Reply to Thread
Results 1 to 4 of 4

Count of Rows in Range ..... does not seem correct

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Count of Rows in Range ..... does not seem correct

    I have the following macro (see enclosed).

    In the macro i attempt to determine the number of rows via these code steps



    MsgBox ("rng rows count is     " & rngSourceData.Rows.Count)
    MsgBox ("rng cols count is   " & rngSourceData.Columns.Count)

    But for some reason the counts are 6 and 6 and i expected 20 and 6.

    Any ideas
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Count of Rows in Range ..... does not seem correct

    any one have any ideas on this one? i am stumped a little on this one.

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Count of Rows in Range ..... does not seem correct

    hi, welchs101, for non-consecutive range you will get only number of rows for the first area (in your case A1:F8) only.

    If you wanted to get total number of rows used, there are several options to use, for example:

    ws.usedrange.rows.count
    result is 20

    If you want to count non-blank cells in rngSourceData:

    Application.CountA(rngSourceData)
    result is 19

  4. #4
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,712

    Re: Count of Rows in Range ..... does not seem correct

    thanks. That is exactly what i wanted to know.......thank you.

+ 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