0

I am looking to build a Analyzer that counts Monthly Dollar Values (columns dating from June2017 to CurrentDate, across 14 different rows) inside of a cell that is Green(Paid) and Orange(Unpaid). I would like to put a COUNTIF Cell at the end of each row and have it tally the cells that are either orange or

So far I've found counting the number of cells that are colored or the number of cells containing a letter. I tried manipulating the code below but I could not figure it out.

Function CountCcolor(range_data As range, criteria As range) As Long     
     Dim datax As range
     Dim xcolor As Long
     xcolor = criteria.Interior.ColorIndex 
     For Each datax In range_data     
         If datax.Interior.ColorIndex = xcolor Then
             CountCcolor = CountCcolor + 1
         End If
     Next datax 
End Function

I have received the #NAME! issue in Excel as well as the cell not counting the numbers but instead how many cells are Green or Orange

Scott Craner
  • 148,073
  • 10
  • 49
  • 81
BMO
  • 1
  • 1
    I think you are confusing `COUNT` and `SUM`. If I have three numbers, say 2, 4 and 7. The `COUNT` of the numbers is how many of them there are (`3`), the `SUM` of the number is their total when they are added together (`13`) – cybernetic.nomad Jul 12 '19 at 15:48
  • 1
    I can't receive the !NAME! issue you're having, but like @cybernetic.nomad said, you need to make that something like `CountCcolor = CountCcolor + datax.Value` – dwirony Jul 12 '19 at 15:50

1 Answers1

0

You get #NAME because Excel does not know what you typed in the cell. Either you mistyped the function name (CountCcolor), typed something unknown as parameters or you placed the VBA function code wrongly. Have you placed the code on a sheet? It has to be in a module which you have to set up by yourself.

bejo
  • 71
  • 7