Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
jinvictor
 
Posts: n/a
Default question about conditional sum


b1:b10 contains numbers in 3 different colours(red, black, blue),what
can i do if i only want the sum of one colour nos, such as sum all
numbers are red colour?


--
jinvictor
------------------------------------------------------------------------
jinvictor's Profile: http://www.excelforum.com/member.php...o&userid=34099
View this thread: http://www.excelforum.com/showthread...hreadid=549800

  #2   Report Post  
Posted to microsoft.public.excel.misc
Nick Hodge
 
Posts: n/a
Default question about conditional sum

Jinvictor

You cannot do this via the UI but you could use a UDF (User Defined
Function) like that below

Function SumColour(rng As Range, ColourCell As Range) As Double
Dim colourNo As Integer, x As Long
Dim myCell As Range
Application.Volatile True
colourNo = ColourCell.Font.ColorIndex
For Each myCell In rng
If myCell.Font.ColorIndex = colourNo Then
x = x + myCell.Value
End If
Next myCell
SumColour =x
End Function

You would enter

=SumColour(B1:B10,B1)

This would sum all cells in B1:B10 that matched the Font colour of B1

To implement in the workbook you want to use it, press Alt+F11 and in the
VBE go to InsertModule and paste the code here, now you can use it as
normal in this workbook

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
HIS


"jinvictor" wrote
in message ...

b1:b10 contains numbers in 3 different colours(red, black, blue),what
can i do if i only want the sum of one colour nos, such as sum all
numbers are red colour?


--
jinvictor
------------------------------------------------------------------------
jinvictor's Profile:
http://www.excelforum.com/member.php...o&userid=34099
View this thread: http://www.excelforum.com/showthread...hreadid=549800



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
YACFQ - Yet Another Conditional Formatting Question... Pheasant Plucker® Excel Discussion (Misc queries) 16 March 22nd 06 05:02 AM
Another Conditional Formating Question RalphSE Excel Worksheet Functions 2 March 16th 06 07:05 PM
Conditional formatting, simple question... Kelly Excel Worksheet Functions 2 March 1st 06 07:31 PM
Conditional Format Not Working KMH Excel Discussion (Misc queries) 0 December 22nd 05 05:32 PM
conditional formatting question Deb Excel Discussion (Misc queries) 0 March 23rd 05 02:07 AM


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