+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    1,487

    How to have a dropdown with Colours as well as Count Cells having a colours?

    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.

  2. #2
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,045

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    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 the icon 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.

  3. #3
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    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

  4. #4
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    1,487

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    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

  5. #5
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,045

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    e4excel, please don't quote whole posts. It's just clutter.
    teylyn
    Microsoft MVP - Excel
    At Excelforum, you can say "Thank you!" by clicking the icon 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.

  6. #6
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    1,487

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    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

  7. #7
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    1,487

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    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

  8. #8
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    1,487

    Bump No Reponse

    Bump No Reponse

  9. #9
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    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

  10. #10
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    This User Defined Function will work in all versions of Excel

    Code:
    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
    The attached example demonstrates both ways
    Attached Files Attached Files
    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

  11. #11
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    1,487

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    Dear RoyUK,

    I would appreciate if you could thro some light on the former reply:

    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.
    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?

  12. #12
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    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

  13. #13
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    1,487

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    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
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    1,487

    Bump No response

    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

  15. #15
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,045

    Re: How to have a dropdown with Colours as well as Count Cells having a colours?

    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 the icon 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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0