+ Reply to Thread
Results 1 to 7 of 7

Count cells that meet certain criteria

  1. #1
    Registered User
    Join Date
    08-07-2018
    Location
    London
    MS-Off Ver
    365
    Posts
    5

    Count cells that meet certain criteria

    Hi everyone,

    I am using VBA to count cells that meet a certain criteria, in this case, cells that contain underlined values/text. The purpose of the script is to provide a reference that will be used in later calculations. The problem is that the current script also outputs zeros, which will effect future calculations. The obvious solution would be to create a new column and blank the cells with a value of zero. However, I will be applying this script to a large number of worksheets so would like to make it as simplified as possible, without having to do any additional modifications to the data after the script has run.

    The current script is:

    Please Login or Register  to view this content.
    I need help in modifying the script so that any calculated zeros are removed.

    Cheers!
    Attached Files Attached Files
    Last edited by Mr_Red; 08-08-2018 at 07:06 AM.

  2. #2
    Forum Contributor
    Join Date
    05-12-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    266

    Re: Count cells that meet certain criteria

    try this one please:

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Count cells that meet certain criteria

    @Mr_Red

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    08-07-2018
    Location
    London
    MS-Off Ver
    365
    Posts
    5

    Re: Count cells that meet certain criteria

    Works a treat!!

  5. #5
    Registered User
    Join Date
    08-07-2018
    Location
    London
    MS-Off Ver
    365
    Posts
    5

    Re: Count cells that meet certain criteria

    Quote Originally Posted by SjonR View Post
    try this one please:

    Please Login or Register  to view this content.
    The formula removes the zero but I've just realized that it doesn't work if the first reference cell is underlined, as it seems to start counting from 0. Is there any way you can modify the script so that the counter starts counting 1, 2, 3, 4 etc as opposed to 0, 1, 2 ?

  6. #6
    Registered User
    Join Date
    08-07-2018
    Location
    London
    MS-Off Ver
    365
    Posts
    5

    Re: Count cells that meet certain criteria

    Sorry, please ignore my above post. Your code actually works fine. The first cell it encountered had a double instead of single underline. Silly me

  7. #7
    Forum Contributor
    Join Date
    05-12-2018
    Location
    Netherlands
    MS-Off Ver
    2016
    Posts
    266

    Re: Count cells that meet certain criteria

    that's great.

    Feel free to add points to my reputation

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Count If cells meet a criteria
    By cmb80 in forum Excel General
    Replies: 3
    Last Post: 08-14-2015, 05:12 AM
  2. [SOLVED] How to count cells that meet two criteria. Please Help!
    By Doolie01 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-18-2013, 02:07 PM
  3. Replies: 2
    Last Post: 03-22-2011, 12:45 PM
  4. Using SUM to count cells that meet multiple criteria
    By cricket_stoner in forum Excel General
    Replies: 10
    Last Post: 05-31-2010, 06:01 AM
  5. count cells that meet criteria
    By bmunoz64 in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 04-01-2009, 08:19 AM
  6. Count cells only if three in a row meet criteria
    By htollefson in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-29-2007, 07:47 AM
  7. How can I count cells that meet two criteria within a filtered co.
    By lizzzy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-21-2005, 02:06 PM

Tags for this Thread

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