Got something to say or just want fewer pesky ads? Join us... 😊

Today's Excel Challenge...











KZNSeagull

Well-known member
Nov 26, 2007
19,790
Wolsingham, County Durham
Right @matt:

Here is the function for counting colours, based on the text colour of a particular cell:

Function SumIfColours(MyRange As Range, TestCell As Range) As Double


Dim cell As Range
Application.Volatile True

For Each cell In MyRange
If cell.Font.ColorIndex = TestCell.Font.ColorIndex Then
SumIfColours = SumIfColours + cell
End If
Next cell

End Function

In the empty cell, type =sumifcolours(A1:A6,A2), where A1:A6 is your range and A2 is and example of the text colour you want to test. You then only need one function and to count different colours, just reference a cell with text of that colour. Make sense?

Press F2 and right tab and the cell should update as per @Buzzer.
 










Official Old Man

Uckfield Seagull
Aug 27, 2011
8,530
Brighton
I'm going down a different route here and should point out I use libre office but can program my own accounts software.
I would have three columns for the figures. 1 = output (invoice total) 2 = input (payment made) 3 = balance. Expanding this to include invoice numbers, dates & customer name.
 






Guinness Boy

Tofu eating wokerati
Helpful Moderator
NSC Patron
Jul 23, 2003
34,073
Up and Coming Sunny Portslade
I'm going down a different route here and should point out I use libre office but can program my own accounts software.
I would have three columns for the figures. 1 = output (invoice total) 2 = input (payment made) 3 = balance. Expanding this to include invoice numbers, dates & customer name.

This looks like it's going double entry.

*faps*
 


KZNSeagull

Well-known member
Nov 26, 2007
19,790
Wolsingham, County Durham
And here is the function for counting cells with text colours:

Function CountColours(MyRange As Range, TestCell As Range) As Double


Dim cell As Range
Application.Volatile True

For Each cell In MyRange
If cell.Font.ColorIndex = TestCell.Font.ColorIndex Then
CountColours = CountColours + 1
End If
Next cell

End Function

Again, if using background colours rather, change ...Font.colorindex to ...Interior.colorindex

I will now write a function to divert @matt 's salary to my bank account....:thumbsup:
 












Albion and Premier League latest from Sky Sports


Top
Link Here