Jump to content

Recommended Posts

Posted

Hi

I was wondering if anybody could give me a helping hand please. I am exporting data from our SIMS into Excel and rather than counting *, =, +, - etc. I would like to count the coloured background of those cells. I can filter the data by the coloured background, but I don't know how to count them (other than manually, obviously).

Grateful for any help!

Thanks

Posted

If it's only a quick count, after filtering if you highlight all the cells it should give a summary of stats including count.

 

If you want it permanently some form of COUNTIF() could be used.

Posted
I was going for the COUNTIF, but when when I tell Excel to look for a = (equal sign) within the designated range, it won't accept that. Now if I could tell Excel to count the number of red coloured cells, that would solve my problem.
Posted
I was going for the COUNTIF, but when when I tell Excel to look for a = (equal sign) within the designated range, it won't accept that. Now if I could tell Excel to count the number of red coloured cells, that would solve my problem.

 

Don't overcomplicate things, count the symbols if you have them.

 

To count "=":
=COUNTIF(RANGE,"==")

To count "+":
=COUNTIF(RANGE,"=+")

To count "-":
=COUNTIF(RANGE,="=-")

  • Thanks 1
Posted
I don't know where to start with VBA - it looks terribly complicated.I'm just using the standard colours red, yellow, dark and light green.
Posted
I don't know where to start with VBA - it looks terribly complicated.I'm just using the standard colours red, yellow, dark and light green.

 

If you must count by colour (and I don't recommend it, see my previous post for Excel formulas that will count the symbols), then you'll want to add this code to a module in your workbook:

 

Public Function cell_colour(Cell_Check As Range) As Long
cell_colour = Cell_Check.Interior.Color
End Function

Public Function count_colour(Count_Range As Range, Colour As Long) As Long
Dim x As Range
count_colour = 0
For Each x In Count_Range
   If x.Interior.Color = Colour Then
       count_colour = count_colour + 1
   End If
Next x
End Function

 

Then you can use those functions in your worksheet like any other excel function, like so:

 

=COUNT_COLOUR(RANGE, CELL_COLOUR(CELL))

 

The range is the range of cells to count, and using the cell_colour function and highlighting a cell that is the same colour as that which you wish to count will get the colour code (simpler than working it out every time)

  • Thanks 1
Posted
This works fine, thank you! But I will try the colour counting as well - been curious about it for quite some time.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...