Consulting

Results 1 to 5 of 5

Thread: Counting Used Cells in a Range

  1. #1

    Counting Used Cells in a Range

    If I write

    Msgbox Range("A1:A10").count
    I get the number of rows in the range.
    How do I write a statement using .Count to get a count of the number of used cells in the range?

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You need to specify what you want to count, in this case Cells.

    Msgbox Range("A1:A10").Cells.Count
    Now what do you mean by used cells? Only cells with values or all cells in the range. If you only want cells with certain values you can use SpecialCells to narrow the range.

  3. #3
    You pretty much told me what I was missing. I just want to know how many of the cells in a column have values.
    I'll investigate the SpecialCells to see what possibilities it offers. Thanx drj!

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

  5. #5
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Quote Originally Posted by DRJ
    You need to specify what you want to count, in this case Cells.

    Msgbox Range("A1:A10").Cells.Count
    Now what do you mean by used cells? Only cells with values or all cells in the range. If you only want cells with certain values you can use SpecialCells to narrow the range.

    .Count
    Simple yet I forgot...
    I must be getting old...

Posting Permissions

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