+ Reply to Thread
Results 1 to 6 of 6

Counting up lists with reference to the cells' colours - possible?

  1. #1
    Registered User
    Join Date
    01-17-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, & 2010 Beta
    Posts
    78

    Counting up lists with reference to the cells' colours - possible?

    I've a list of numbers I go through (testing them). My test will determine one of 2 things: that a number is to be 'rejected', so I count it out by selecting the cell and clicking a macro that recolors it to a blue background with blue font. Or my test determines that a number is to be 'kept' and I mark that by selecting that cell and using another macro that changes the cell's colors differently (yellow background with brown font). So it's sort of visual. But I'd like a formula to count up the total number of blue-on blues I have, as well as the yellows-on-brown. Are their values we can use in formulas to denote specific colours in cells? Something the equivalent of: countif(range of number values, colour=yellow)...if you follow me. Thanks for any help.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Counting up lists with reference to the cells' colours - possible?

    Have a look at this superb write up by AbleBits
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Counting up lists with reference to the cells' colours - possible?

    Formulas cannot do this but since you are already using macros, you could add a user-defined function (UDF) in your macros that can then be used in formulas. If you provide the macro that does the colors, then I can show you a macro to count the colors. You could do something like this:

    Please Login or Register  to view this content.
    Then your sheet:

    =COUNTREJECTED(A1:Z99)

    Or whatever the actual range is you want to count.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Counting up lists with reference to the cells' colours - possible?

    Similar to 6StringJazzer

    First range is "Count Range", second range is "Base cell"
    -See attached workbook for working examples (formulas in cells E4 to G5)


    3 UDFs
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-17-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, & 2010 Beta
    Posts
    78

    Re: Counting up lists with reference to the cells' colours - possible?

    Hi 6String..., thank you very much for this.
    Here's one macro (one set of colours):
    Sub EliminateSelectedPermutations()
    '
    ' EliminateSelectedPermutations Macro
    '

    '
    ActiveSheet.Unprotect
    With Selection.Font
    .Name = "Bookman Old Style"
    .FontStyle = "Regular"
    .Size = 14
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    .TintAndShade = 0
    .ThemeFont = xlThemeFontNone
    End With
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent1
    .TintAndShade = 0.599963377788629
    .PatternTintAndShade = 0
    End With
    End Sub

    and here is the other one:

    Sub KeepThisPerm()
    '
    ' KeepThisPerm Macro
    '

    '
    ActiveSheet.Unprotect
    With Selection.Font
    .Name = "Bookman Old Style"
    .FontStyle = "Regular"
    .Size = 14
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .Color = 192
    .TintAndShade = 0
    .ThemeFont = xlThemeFontNone
    End With
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .ThemeColor = xlThemeColorAccent4
    .TintAndShade = 0.599963377788629
    .PatternTintAndShade = 0
    End With
    ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
    False
    End Sub

    If you can fashion me one of these UDF's, I'd be very grateful indeed. Many thanks,
    Lotusman

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,388

    Re: Counting up lists with reference to the cells' colours - possible?

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Counting Colours
    By burgie10 in forum Excel General
    Replies: 4
    Last Post: 04-24-2015, 05:36 AM
  2. Counting Cell Colours
    By Willows in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-28-2014, 09:45 AM
  3. [SOLVED] Counting cells based on colours and contents
    By bond002 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-12-2014, 08:58 AM
  4. Counting Colours
    By matthew.lawson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-06-2013, 07:03 AM
  5. Replies: 25
    Last Post: 03-29-2010, 03:23 PM
  6. Counting Cells with Variable Reference
    By yensid in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-31-2009, 03:57 AM
  7. Counting cells by colours rather than by content
    By wbleamas in forum Excel General
    Replies: 1
    Last Post: 11-02-2008, 04:23 AM

Tags for this Thread

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.6.0 RC 1