total using colour?

jackdiamond

Board Regular
Joined
Oct 10, 2007
Messages
220
Hi,

Is there anyway to get a total but only using colours?

eg, I want to colour blocks in blue and at the end of the row, I want it to count how many were blue.

Can this be done?

Thanks
Stu
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
thanks, however, I am very slow at excel and can't make head nor tail of this?!

Could you help by any chance please?


I just need to count how many cells have blue in! (or any other colour)

Thanks
 
Upvote 0
Could you please let me know the version of Excel that you are using on your computer ? It will hep me to guide you in the right kind of direction.
 
Upvote 0
Hi Stu,

You could try this...

Place the macro below in a standard module. Press Alt+F11 to enter the VBE > add a module and paste on the right side of the screen.

Excel Workbook
IJK
1***
2***
3***
4**2
Sheet2



Code:
Function COUNTCOLOR(rColor As Range, rCountRange As Range)
Dim rCell As Range
Dim iCol As Integer
Dim Result

Application.Volatile

iCol = rColor.Interior.ColorIndex

For Each rCell In rCountRange
If rCell.Interior.ColorIndex = iCol Then
Result = Result + 1
End If
Next rCell
'=COUNTCOLOR(K4,I1:J4)
'Where K4 houses the colour of choice (e.g. blue)
COUNTCOLOR = Result
End Function
 
Upvote 0
ok, I press Alt+F11 to enter the VBE, I then insert module? Once the box comes up, I copy and paste the macro below.

What do I do now? How can i get that into my spreadsheet?

Apologies but I have never used VBE before

Any help appreciated!!!

Or if it is more helpful, could someone email me a version?!! stuart.longhurst@catalent.com

thank you very much
Stu
 
Upvote 0
Hi Stu,

That is good...you have pasted the Function in a standard module now all you have to do is enter the formula =COUNTCOLOR(K4,I1:J4) into your spreadsheet where K4 house the color you would like to count.

In the example I posted I1:J4 is the range being evaluated.
 
Upvote 0
Thanks for the email Jeff.

So I can do it myself in the future, once I have copied the section into VBE, how do I then get it so it is on the spreadsheet?

thanks
Stu
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,551
Members
449,170
Latest member
Gkiller

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top