+ Reply to Thread
Results 1 to 14 of 14

Count the number of highlighted cells

  1. #1
    Registered User
    Join Date
    06-12-2008
    Posts
    19

    Count the number of highlighted cells

    For some reason the search is not working. I want to count the number of cells that I select whether it be in one or more columns or rows. I would like the number to be displayed at the bottom of the page. I have seen this done, but I cannot recall how it was done. Do I need to write a macro or just do a modified countif formula?

  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
    Right click the status bar and select count

    http://www.bettersolutions.com/excel...B913232322.htm

    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
    06-12-2008
    Posts
    19
    That did not work. It keeps coming up with zero for the count. I have a filter on that is looking for blanks if that makes a difference. Also, the blanks are scattered throughout the list so they have random cell numbers.

  4. #4
    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
    It won't work as you suspected. If you give all the info you stand a better chance of getting an answer

    Would a formula work

    =COUNTBLANK(A2:A21)
    VBA Noob

  5. #5
    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
    Maybe

    Please Login or Register  to view this content.
    VBA Noob

  6. #6
    Registered User
    Join Date
    06-12-2008
    Posts
    19
    That doesn't seem to work. I am pasting it into the current workbook selection in the VBA code editor so it should, and the code does make sense. I really do not see why it does not work.

  7. #7
    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
    Code goes in a normal module.

    Press Alt + F11 to open VB > select Insert Module and paste > close editor press Alt + F8 and call CntCells

    VBA Noob

  8. #8
    Registered User
    Join Date
    06-12-2008
    Posts
    19
    I got it to run, but it is essentially counting the last number on the filter and subtracting the first from it. (i.e. The last item is number 76 and the first one is 33. The answer you get is 43. However, there are only 6 cells after I run the filter.

  9. #9
    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
    Quote Originally Posted by Ford_Guy
    I got it to run, but it is essentially counting the last number on the filter and subtracting the first from it. (i.e. The last item is number 76 and the first one is 33. The answer you get is 43. However, there are only 6 cells after I run the filter.

    You started off asking to count selected cells. Are you now asking to subtract the first filtered value from the last filtered Item

    Maybe you need to upload an example or have a thing about what you want

    VBA Noob

  10. #10
    Registered User
    Join Date
    06-12-2008
    Posts
    19
    I do want it count the selected cells. I was telling you what it was doing. It isn't counting them. It is doing some sort of subtraction. The file is too big to attach right now. I will make it smaller tomorrow. I hope that explanation helps, but if not I will go into more detail when I have more time.

  11. #11
    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
    I do want it count the selected cells
    Not what your title says.

    The file is too big to attach right now
    You don't have to attach the actual file. Just a small amount of data with the expected results

    VBA Noob

  12. #12
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    One solution

    If you want to count the number of visible cells after using Autofilter, then use the formula =SUBTOTAL(3,A2:A100).
    If you want to count Only Numbers, use number 4 instead of 3 in the formula. And if you want to summarise, use number 9.

    Hope this helps
    Ola

  13. #13
    Registered User
    Join Date
    06-12-2008
    Posts
    19
    Olasa,

    Thank you for the response. That works perfectly. I did not know about the subtotal function.

  14. #14
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    Count or sum only Visible rows

    Thanks for the feedback
    //Ola

+ 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