Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How to add cells with a particular background color?

If I have a column with amounts and I color code these with different
colors...... How do I write a formula to add all the dark greens in one cell
and browns in another, and or yellows in another, etc?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 461
Default How to add cells with a particular background color?

You would need to use VBA to accomplish this.

"BruceN1" wrote:

If I have a column with amounts and I color code these with different
colors...... How do I write a formula to add all the dark greens in one cell
and browns in another, and or yellows in another, etc?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default How to add cells with a particular background color?

How difficult is this

"akphidelt" wrote:

You would need to use VBA to accomplish this.

"BruceN1" wrote:

If I have a column with amounts and I color code these with different
colors...... How do I write a formula to add all the dark greens in one cell
and browns in another, and or yellows in another, etc?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default How to add cells with a particular background color?

Read instructions at Chip Pearson's site then copy the functions provided to a
general module in your workbook.

http://www.cpearson.com/excel/colors.htm

Or download the EasyFilter add-in from Ron de Bruin's site.

http://www.rondebruin.nl/easyfilter.htm


Gord Dibben MS Excel MVP

On Fri, 29 Feb 2008 11:39:03 -0800, BruceN1
wrote:

How difficult is this

"akphidelt" wrote:

You would need to use VBA to accomplish this.

"BruceN1" wrote:

If I have a column with amounts and I color code these with different
colors...... How do I write a formula to add all the dark greens in one cell
and browns in another, and or yellows in another, etc?


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,069
Default How to add cells with a particular background color?

Here is a user-defined function which returns the colorindex of a single
cell. Call it like this to get the interior (fill) color: =GetColorIndex(B27)
or call it like this if you want the font color: =GetColorIndex(B27,"Font")
Use the function in an empty column to get colorindex of all your data
cells. Then you can use SUMIF to add all the cells which have the same
colorindex.

Paste the following code into a VBA module in your workbook. From the Tools
menu, select Macro, then Visual Basic Editor. In the Visual Basic Editor,
Select Project Explorer from the View menu. Probably along the left side of
your screen, you should see VBAProject followed by the name of your workbook.
Click on that, then select Module from the Insert menu. Paste the code in the
blank module that appears.

Public Function GetColorIndex(Target As Range, Optional WhichType As String)
As Variant
If Target.Count 1 Then
GetColorIndex = "ERROR"
Exit Function
End If
If WhichType = "Font" Then
GetColorIndex = Target.Font.ColorIndex
Else
GetColorIndex = Target.Interior.ColorIndex
End If
End Function

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Hope this helps,

Hutch

"BruceN1" wrote:

How difficult is this

"akphidelt" wrote:

You would need to use VBA to accomplish this.

"BruceN1" wrote:

If I have a column with amounts and I color code these with different
colors...... How do I write a formula to add all the dark greens in one cell
and browns in another, and or yellows in another, etc?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I sum depending on the background color of cells in Excel? Erik MITON Excel Discussion (Misc queries) 1 December 14th 07 12:11 AM
change background color in cells Joe Excel Worksheet Functions 4 November 6th 07 11:20 PM
Color background with Matching cells in row Diggsy Excel Worksheet Functions 6 January 31st 06 08:58 PM
cell background color while searching through cells MatthewTap Excel Discussion (Misc queries) 1 January 17th 06 08:00 PM
How do you count cells with background color yellow? Stephanie D Excel Discussion (Misc queries) 6 October 18th 05 04:34 AM


All times are GMT +1. The time now is 09:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"