PC Review


Reply
Thread Tools Rate Thread

Conditional Formatted numbers add based on color?

 
 
=?Utf-8?B?TWl0Y2g=?=
Guest
Posts: n/a
 
      14th Sep 2007
I'm wondering how to Add red numbers together in a column and blue numbers in
a column. I've conditionally formatted them based on a text string (CAD/USD)
but the macro I've found isn't working, I believe it's not working because
the cells are conditionally formatted.

Not my code, forget were I got it from.

Function SumColor(rColor As Range, rSumRange As Range)

Dim rCell As Range
Dim iCol As Integer
Dim vResult

iCol = rColor.Interior.ColorIndex

For Each rCell In rSumRange
If rCell.Interior.ColorIndex = iCol Then
vResult = WorksheetFunction.Sum(rCell) + vResult
End If
Next rCell

SumColor = vResult
End Function


 
Reply With Quote
 
 
 
 
Jim Rech
Guest
Posts: n/a
 
      14th Sep 2007
>> I believe it's not working because the cells are conditionally formatted.

I believe you're right. The last time I checked it did not seem possible to
directly check the formatting that conditional formatting was currently
applying. I think the only thing you can do is extract the 'conditions',
evaluate their current values and then extract what formats would be applied
based on them. All this using the range FormatConditions object. Quite the
hassle.

--
Jim
"Mitch" <(E-Mail Removed)> wrote in message
news:295B49AA-97AC-451B-953B-(E-Mail Removed)...
> I'm wondering how to Add red numbers together in a column and blue numbers
> in
> a column. I've conditionally formatted them based on a text string
> (CAD/USD)
> but the macro I've found isn't working, I believe it's not working because
> the cells are conditionally formatted.
>
> Not my code, forget were I got it from.
>
> Function SumColor(rColor As Range, rSumRange As Range)
>
> Dim rCell As Range
> Dim iCol As Integer
> Dim vResult
>
> iCol = rColor.Interior.ColorIndex
>
> For Each rCell In rSumRange
> If rCell.Interior.ColorIndex = iCol Then
> vResult = WorksheetFunction.Sum(rCell) + vResult
> End If
> Next rCell
>
> SumColor = vResult
> End Function
>
>



 
Reply With Quote
 
=?Utf-8?B?TWl0Y2g=?=
Guest
Posts: n/a
 
      19th Sep 2007
Any suggestions on how to get the color change based on a text string? (Even
if you can provide just the function in the scripting language I can probably
get the rest done. Well how do you get it to pick the column to the left of
where you start. C10 has the numbers that I want changed to red or blue, and
C9 has the text USD or CDN.

Then I have to add up the C10 values based on Red or Blue.

Wish there was some good documention on the Excel/VBA .. or haven't found it
yet.

"Jim Rech" wrote:

> >> I believe it's not working because the cells are conditionally formatted.

>
> I believe you're right. The last time I checked it did not seem possible to
> directly check the formatting that conditional formatting was currently
> applying. I think the only thing you can do is extract the 'conditions',
> evaluate their current values and then extract what formats would be applied
> based on them. All this using the range FormatConditions object. Quite the
> hassle.
>
> --
> Jim
> "Mitch" <(E-Mail Removed)> wrote in message
> news:295B49AA-97AC-451B-953B-(E-Mail Removed)...
> > I'm wondering how to Add red numbers together in a column and blue numbers
> > in
> > a column. I've conditionally formatted them based on a text string
> > (CAD/USD)
> > but the macro I've found isn't working, I believe it's not working because
> > the cells are conditionally formatted.
> >
> > Not my code, forget were I got it from.
> >
> > Function SumColor(rColor As Range, rSumRange As Range)
> >
> > Dim rCell As Range
> > Dim iCol As Integer
> > Dim vResult
> >
> > iCol = rColor.Interior.ColorIndex
> >
> > For Each rCell In rSumRange
> > If rCell.Interior.ColorIndex = iCol Then
> > vResult = WorksheetFunction.Sum(rCell) + vResult
> > End If
> > Next rCell
> >
> > SumColor = vResult
> > End Function
> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
add value of cells based on the formatted fill color mike Microsoft Excel Worksheet Functions 3 5th Nov 2009 07:41 PM
Conditional Formatting - Color row based on one cell value =?Utf-8?B?TW9uaWNh?= Microsoft Excel Programming 1 6th Nov 2007 07:40 PM
Copy current color of conditional formatted cell =?Utf-8?B?anVzdG1l?= Microsoft Excel Programming 4 18th Oct 2007 01:17 PM
sum by conditional formatted color =?Utf-8?B?RGF2ZSBG?= Microsoft Excel Misc 2 14th Mar 2007 05:35 PM
Conditional Formatted Cell Color Index =?Utf-8?B?TURSNTMwMA==?= Microsoft Excel Programming 5 27th Jan 2005 09:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:32 AM.