VBA: Count the Number of Used Rows

September 7th, 2004 | Categories: VBA | Tags: , ,
-->

The following code will return in a message box the total number of rows used in a worksheet. Empty rows are considered used if data follows the empty row.

MsgBox ActiveSheet.UsedRange.Rows.Count
Can't get the tutorial to work for you? Need help with your code?
Get answers right away at our AE Excel Support Forums!
  1. Dimo
    August 19th, 2009 at 13:38
    Reply | Quote | #1

    MsgBox ActiveSheet.UsedRange.Columns.Count

    Works for columns’ number

  2. November 22nd, 2009 at 18:53
    Reply | Quote | #2

    You save my day! thanks, it really helps.

  3. Hank Gerdes
    December 13th, 2010 at 21:36
    Reply | Quote | #3

    Not what I want.. I need to count the number of used ( non blank ) cells in a column that may or may not have blank cells. Esample column “AF” has cells in row 12, 35, 256. The answer is 3. There are 3 “used” cells in “AF”.

  4. Ace
    February 23rd, 2011 at 20:16
    Reply | Quote | #4

    Try:

    MsgBox WorksheetFunction.CountA(AF:AF)

  5. Puneet Goel
    April 1st, 2011 at 09:09
    Reply | Quote | #5

    Thanks a ton, wish I got this earlier :-)

  6. Akash Kundu
    May 24th, 2011 at 12:39
    Reply | Quote | #6

    Thanks a ton!!!!