Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 68
Default Conditional Sum Based on Cell Background Color

Excel 2007

I had an Outlook reminder (5 weeks overdue) come up today prompting me to do
some work on getting Excel to do a conditional sum based on cell background
color. The thing is, I can't remember if I've already posted a question
about this, or if the reminder was intended to prompt me to post a question.
Either way, I can't find any indication that I have previously posed this
query. So, I apologize if this is a repeat question.

I have the following numbers in A2:A8. I've indicated the background color
for each value.

53
12 Green
42 Red
89 Green
36 Green
71
20 Red

I would like to know if there is a way to do a conditional sum based on the
background color of the cells. So, for example, a formula that keys on
green would produce a result of 137. I've found some information implying
that the following formula should work to sum all red cells:

=SUMPRODUCT(--(colorindex(A2:A8)=3),A2:A8)

However, that formula yields a #NAME? error, which I assume is caused by the
fact that Excel does not recognize the colorindex function. So I suspect
that colorindex is a custom function. My question then would be, where do I
get the colorindex function? I suppose that a second question would be, am
I on the right track?

--Tom


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 68
Default Conditional Sum Based on Cell Background Color

Okay, this is embarrassing, but I just discovered that I already have the
function in the ThisWorkbook code module. So I guess the new question would
be, if I have the custom function why isn't it being recognized by Excel?

--Tom

"Thomas M." wrote in message
...
Excel 2007

I had an Outlook reminder (5 weeks overdue) come up today prompting me to
do some work on getting Excel to do a conditional sum based on cell
background color. The thing is, I can't remember if I've already posted a
question about this, or if the reminder was intended to prompt me to post
a question. Either way, I can't find any indication that I have previously
posed this query. So, I apologize if this is a repeat question.

I have the following numbers in A2:A8. I've indicated the background
color for each value.

53
12 Green
42 Red
89 Green
36 Green
71
20 Red

I would like to know if there is a way to do a conditional sum based on
the background color of the cells. So, for example, a formula that keys
on green would produce a result of 137. I've found some information
implying that the following formula should work to sum all red cells:

=SUMPRODUCT(--(colorindex(A2:A8)=3),A2:A8)

However, that formula yields a #NAME? error, which I assume is caused by
the fact that Excel does not recognize the colorindex function. So I
suspect that colorindex is a custom function. My question then would be,
where do I get the colorindex function? I suppose that a second question
would be, am I on the right track?

--Tom



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,071
Default Conditional Sum Based on Cell Background Color

Post the function. HTH Otto
"Thomas M." wrote in message
...
Okay, this is embarrassing, but I just discovered that I already have the
function in the ThisWorkbook code module. So I guess the new question
would be, if I have the custom function why isn't it being recognized by
Excel?

--Tom

"Thomas M." wrote in message
...
Excel 2007

I had an Outlook reminder (5 weeks overdue) come up today prompting me to
do some work on getting Excel to do a conditional sum based on cell
background color. The thing is, I can't remember if I've already posted
a question about this, or if the reminder was intended to prompt me to
post a question. Either way, I can't find any indication that I have
previously posed this query. So, I apologize if this is a repeat
question.

I have the following numbers in A2:A8. I've indicated the background
color for each value.

53
12 Green
42 Red
89 Green
36 Green
71
20 Red

I would like to know if there is a way to do a conditional sum based on
the background color of the cells. So, for example, a formula that keys
on green would produce a result of 137. I've found some information
implying that the following formula should work to sum all red cells:

=SUMPRODUCT(--(colorindex(A2:A8)=3),A2:A8)

However, that formula yields a #NAME? error, which I assume is caused by
the fact that Excel does not recognize the colorindex function. So I
suspect that colorindex is a custom function. My question then would be,
where do I get the colorindex function? I suppose that a second question
would be, am I on the right track?

--Tom





  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 68
Default Conditional Sum Based on Cell Background Color

The code is not mine, so I don't think that I should be posting it without
the author's permission. However, I can give link to where I found the
code. The complete block of code is found under Code Samples at the bottom
of the page.

http://xldynamic.com/source/xld.ColourCounter.html#code

--Tom

"Otto Moehrbach" wrote in message
...
Post the function. HTH Otto
"Thomas M." wrote in message
...
Okay, this is embarrassing, but I just discovered that I already have the
function in the ThisWorkbook code module. So I guess the new question
would be, if I have the custom function why isn't it being recognized by
Excel?

--Tom

"Thomas M." wrote in message
...
Excel 2007

I had an Outlook reminder (5 weeks overdue) come up today prompting me
to do some work on getting Excel to do a conditional sum based on cell
background color. The thing is, I can't remember if I've already posted
a question about this, or if the reminder was intended to prompt me to
post a question. Either way, I can't find any indication that I have
previously posed this query. So, I apologize if this is a repeat
question.

I have the following numbers in A2:A8. I've indicated the background
color for each value.

53
12 Green
42 Red
89 Green
36 Green
71
20 Red

I would like to know if there is a way to do a conditional sum based on
the background color of the cells. So, for example, a formula that keys
on green would produce a result of 137. I've found some information
implying that the following formula should work to sum all red cells:

=SUMPRODUCT(--(colorindex(A2:A8)=3),A2:A8)

However, that formula yields a #NAME? error, which I assume is caused by
the fact that Excel does not recognize the colorindex function. So I
suspect that colorindex is a custom function. My question then would
be, where do I get the colorindex function? I suppose that a second
question would be, am I on the right track?

--Tom







  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 68
Default Conditional Sum Based on Cell Background Color

I forgot to mention that I copied and pasted the code exactly as it appears
on the author's Web site. Also, upon a closer reading of my research notes,
I see where there are instructions for creating a new code module and
pasting the code into that module, which I have also done.

--Tom

"Thomas M." wrote in message
...
The code is not mine, so I don't think that I should be posting it without
the author's permission. However, I can give link to where I found the
code. The complete block of code is found under Code Samples at the
bottom of the page.

http://xldynamic.com/source/xld.ColourCounter.html#code

--Tom

"Otto Moehrbach" wrote in message
...
Post the function. HTH Otto
"Thomas M." wrote in message
...
Okay, this is embarrassing, but I just discovered that I already have
the function in the ThisWorkbook code module. So I guess the new
question would be, if I have the custom function why isn't it being
recognized by Excel?

--Tom

"Thomas M." wrote in message
...
Excel 2007

I had an Outlook reminder (5 weeks overdue) come up today prompting me
to do some work on getting Excel to do a conditional sum based on cell
background color. The thing is, I can't remember if I've already
posted a question about this, or if the reminder was intended to prompt
me to post a question. Either way, I can't find any indication that I
have previously posed this query. So, I apologize if this is a repeat
question.

I have the following numbers in A2:A8. I've indicated the background
color for each value.

53
12 Green
42 Red
89 Green
36 Green
71
20 Red

I would like to know if there is a way to do a conditional sum based on
the background color of the cells. So, for example, a formula that
keys on green would produce a result of 137. I've found some
information implying that the following formula should work to sum all
red cells:

=SUMPRODUCT(--(colorindex(A2:A8)=3),A2:A8)

However, that formula yields a #NAME? error, which I assume is caused
by the fact that Excel does not recognize the colorindex function. So
I suspect that colorindex is a custom function. My question then would
be, where do I get the colorindex function? I suppose that a second
question would be, am I on the right track?

--Tom











  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Conditional Sum Based on Cell Background Color

You still get an error?

Using Bob's function I get 62 with your formula and data example.

Alt + F11 to open the Visual Basic Editor.

CTRL + r to open Project Explorer.

Right-click on your project/workbook and InsertModule

Paste all of Bob's code into that module.

Alt + q to return to Excel.

Enter your formula in a cell.


Gord Dibben MS Excel MVP

On Wed, 14 Oct 2009 15:01:23 -0600, "Thomas M."
wrote:

I forgot to mention that I copied and pasted the code exactly as it appears
on the author's Web site. Also, upon a closer reading of my research notes,
I see where there are instructions for creating a new code module and
pasting the code into that module, which I have also done.

--Tom

"Thomas M." wrote in message
...
The code is not mine, so I don't think that I should be posting it without
the author's permission. However, I can give link to where I found the
code. The complete block of code is found under Code Samples at the
bottom of the page.

http://xldynamic.com/source/xld.ColourCounter.html#code

--Tom

"Otto Moehrbach" wrote in message
...
Post the function. HTH Otto
"Thomas M." wrote in message
...
Okay, this is embarrassing, but I just discovered that I already have
the function in the ThisWorkbook code module. So I guess the new
question would be, if I have the custom function why isn't it being
recognized by Excel?

--Tom

"Thomas M." wrote in message
...
Excel 2007

I had an Outlook reminder (5 weeks overdue) come up today prompting me
to do some work on getting Excel to do a conditional sum based on cell
background color. The thing is, I can't remember if I've already
posted a question about this, or if the reminder was intended to prompt
me to post a question. Either way, I can't find any indication that I
have previously posed this query. So, I apologize if this is a repeat
question.

I have the following numbers in A2:A8. I've indicated the background
color for each value.

53
12 Green
42 Red
89 Green
36 Green
71
20 Red

I would like to know if there is a way to do a conditional sum based on
the background color of the cells. So, for example, a formula that
keys on green would produce a result of 137. I've found some
information implying that the following formula should work to sum all
red cells:

=SUMPRODUCT(--(colorindex(A2:A8)=3),A2:A8)

However, that formula yields a #NAME? error, which I assume is caused
by the fact that Excel does not recognize the colorindex function. So
I suspect that colorindex is a custom function. My question then would
be, where do I get the colorindex function? I suppose that a second
question would be, am I on the right track?

--Tom









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
Changing Cell Background Color based on data from another cell Speedy Excel Discussion (Misc queries) 2 March 16th 09 04:10 PM
change the color of cell background based on a result Rich Excel Worksheet Functions 2 January 27th 09 07:17 PM
Find cells w/background color based on conditional formatting Freida Excel Worksheet Functions 2 November 17th 08 07:36 PM
Changing background color based on different cell djarcadian Excel Discussion (Misc queries) 3 August 10th 06 10:44 PM
Conditional cell background formatting, based on cell content nosivad Excel Discussion (Misc queries) 5 February 11th 06 11:12 PM


All times are GMT +1. The time now is 07:22 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"