How to have a dropdown with Colours as well as Count Cells having a colours?
Dear Forum,
I wanted to get a Dropdown which displays colours instead of the Colour Name and also if lets say I have ten cells having a Fill-Colour Red then I should be able to get the Count based on the colour.
Ex: I Select Fill Colour in cells A1 till A1o REd then In Cell G1 I have this Colour Drop-Down on selcting Red I should get the count Ten in Cell H1
Usually, we do the vice versa but over here I want to get the Count based on simply the colour and keep the cells empty of data..
I think this would be possible through VBA so i am open for it..
Thanks in advance...
Last edited by e4excel; 03-26-2010 at 07:11 AM.
Why use a drop down box for color when you can simply use the fill color functionality?
teylyn
Microsoft MVP - Excel
At Excelforum, you can say "Thank you!" by clicking theicon below the post.
Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.
Your note on 2007 doesn't help us,we need to know what version you are using,not your opinion of 2007!
If you have Excel2007 you can count by colours
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
I am having Excel 2007 which I find really difficult to use and am not aware of any such feature which allows me to do the same. If so please explain..
Also I am using Fill Colour to get a cj=hoice of 10 to 15 Exclusive colours in the Dropdpwn...
Last edited by teylyn; 03-17-2010 at 05:01 AM. Reason: removed spurious quote
e4excel, please don't quote whole posts. It's just clutter.
teylyn
Microsoft MVP - Excel
At Excelforum, you can say "Thank you!" by clicking theicon below the post.
Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.
Ok I shall take care of that!
I just thought it was anyways very small.
But can you please help me on the information of using thefeature via Excel 2007
Deer Forum,
If it already exists please let me know how do i use this feature? of Counting colurs in Excel 2007 and if not then I want to get actual colours displayed in a Dropdown if thats possible via VBA...
I am looking to have set of 10-15 colours which would be exclusively used for my work and then I need to count these used colurs..
Please can someone help me on this..
Warm Regards
e4excel![]()
Bump No Reponse
With Excel2007 you can filter by a colour,so the simplest way would be to combine this with a SUBTOTAL Function. Otherwise to count or sum by colours you would need VBA.
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
This User Defined Function will work in all versions of Excel
The attached example demonstrates both waysCode:Option Explicit '''''''''''''''''''''''''''''''''''''' 'Sums or counts cells based on a specified fill Colour. ''''''''''''''''''''''''''''''''''''''' Function ColourFunction(rColour As Range, rRange As Range, Optional SUM As Boolean) Dim rCl As Range Dim rRng As Range Dim lCol As Long Dim vResult lCol = rColour.Interior.ColorIndex For Each rCl In rRange If rCl.Interior.ColorIndex = lCol Then If rRng Is Nothing Then Set rRng = rCl Else: Set rRng = Union(rCl, rRng) End If End If vResult = WorksheetFunction.SUM(rCl, vResult) Next rCl If SUM = True Then vResult = Application.WorksheetFunction.SUM(rRng) Else: vResult = rRng.Cells.Count End If ColourFunction = vResult End Function Sub TestCount() MsgBox ColourFunction(Range("a2"), Range("A2:a4")) End Sub Sub testSum() MsgBox ColourFunction(Range("a2"), Range("A2:a4"), True) End Sub
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
Dear RoyUK,
I would appreciate if you could thro some light on the former reply:
and honestly speaking I did not understand how to use the file can you also explain what do I do in that as I m no good in using Filters?With Excel2007 you can filter by a colour,so the simplest way would be to combine this with a SUBTOTAL Function. Otherwise to count or sum by colours you would need VBA.
AutoFilter is basic in Excel.
Click the drop down in A1, you will see an option to Filter by color. Filter the data & the SUBTOTALS will adjust.
THE VBA UDF has examples how to use it, but until you learn basic Excel features I would suggest that you do not attempt any VBA
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
Check out the free Excel Toolbar
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
Code Tags: Make your code easier for us to read
Dear RoyUk,
I have attached a file can something be done based on the file?
I am not sure whether that would be possible with formula but I am ok with VBA too..
Warm Rgrds
Dear RoyUK,
I have attached a file as a last try incase something can be worked on the specifications or else I will have to tweak on the logic used in your earlier file..
Warm Regards
e4excel
e4excel, why don't you take up Roy's suggestion from above and learn about the use of basic Excel features before you tackle anything as complex as VBA. VBA is great to extend existing functionality, but if you don't have an understanding of that functionality and what it can deliver in the first place, how, do you imagine, will you ever manage VBA?
teylyn
Microsoft MVP - Excel
At Excelforum, you can say "Thank you!" by clicking theicon below the post.
Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks