Forum Discussion

John null's avatar
John null
Copper Contributor
Oct 15, 2018

How can I count cells with numbers?

Hi,

I have a range of data that are formatted and wanted to know if there is a way to find the frequency/count for specific formatted ( by font or by fill color) cells along with the number inside the cell. Please see the excel sheet attached. I tried using a color-count VBA code but I am having trouble creating a condition where two criteria have to be met; 1) font/fill color 2) the number(s) (inside the cell) before beginning to count.  Overall, I am trying to compute the frequency of these numbers that are conditionally formatted. Any help will be much appreciated.

  • Hi John,

     

    Perhaps you may use you conditional formatting rule formula

    =SUMPRODUCT(--($A$1:$E$325=OFFSET($A$1:$E$325,1,0)))

    to count cells under the rule and

    =SUMPRODUCT(--($A$1:$E$325=OFFSET($A$1:$E$325,1,0))*(($A$1:$E$325=I3)))

    for frequency

    • John null's avatar
      John null
      Copper Contributor

      Hi Sergei,

      The formula below worked great! Unfortunately, I cannot get it to work with a different conditionally formatted cells. I am now trying to find the frequency on numbers and cannot find a solution. Please see the excel attached. I will appreciate any help. 

      • SergeiBaklan's avatar
        SergeiBaklan
        MVP

        Hi John,

         

        Since your conditional formatting rule formula is

        =A1+1=B1

        the formula to calculate such pairs will be

        =SUMPRODUCT(($A$1:$E$108+1=OFFSET($A$1:$E$108,0,1))*(($A$1:$E$108=0+LEFT(H2,SEARCH(",",H2)-1))))

        First multiplier emulates your conditional formatting rule formula. Second one selects concrete pair from your list. 0+ is needed to convert text returned by LEFT to number (could be VALUE())

        Attached.

         

         

    • John null's avatar
      John null
      Copper Contributor

      Hi Sergei,

      I am wondering how can I modify the below equation:

      =SUMPRODUCT(--($A$1:$E$325=OFFSET($A$1:$E$325,1,0))*(($A$1:$E$325=I3)))

      To make it count numbers that have been recycled in the previous row (current formula above only counts the below number but fails to count a recycled number that is not under it). I've managed to complete a conditional format that will highlight them in red but I cannot figure out on how to count the actual number of times the number was recycled given a data set. Please see the attached file.

       

      • SergeiBaklan's avatar
        SergeiBaklan
        MVP

        Hi John,

         

        To clarify - you count the numbers which are in next row in the same and next columns (34, 24 on screenshot), but not in previous columns (28), correct?

         

Resources