+ Reply to Thread
Results 1 to 13 of 13

Coun cells with colour and text help please

  1. #1
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Question Coun cells with colour and text help please

    I have a sheet called "data" and in it there is a range of cells named "players". Some of the cells have a background colour of red (due to being sent off).

    On Sheet called "Players" I want a column that counts the number of times a players name has a red background in the data sheet.

    For example:

    Sheet "Data"
    Range "players"


    Sheet "Players"
    Cell "Z1" has the player name "Jones.J"
    in Cell "AA1" I want it to count the number of times "Jones.J" appears WITH a "red" background in the datasheet "data" in the range "players".

    Is this possible?
    if yes .. How?
    Please.
    A mad football researcher and Statistician - ok just mad really !

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Coun cells with colour and text help please

    See http://www.xldynamic.com/source/xld.....html#counting

  3. #3
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Re: Coun cells with colour and text help please

    Thanks.

    I get that using

    =SUMPRODUCT(--(ColorIndex(A1:A100)=3))

    Will return all the cells with a red backgroud, but I additionally I need it to count those with Jones.J AND a red background.

    How can I do this?

  4. #4
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Coun cells with colour and text help please

    Try

    =SUMPRODUCT(--(ColorIndex(A1:A100)=3),--(A1:A100="Jones J."))

  5. #5
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Re: Coun cells with colour and text help please

    I have made the full ranges of cells that can have the red background named SendOffs (not original I know) and the players name is in cell P871

    Therefore in excel 2002 the formula should be
    =SUMPRODUCT(--(ColorIndex(SendOffs)=3),--(SendOffs=P871))

    Is this correct?

    If so why is it showing #NAME? ?
    Last edited by Lensmeister; 09-08-2011 at 03:29 PM.

  6. #6
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Re: Coun cells with colour and text help please

    This may sound a little silly, but do you have the code for the UDF installed already on your workbook?

    You need to put the code provided on a separate module.
    Ron
    Knowledge is knowing that a tomato and pepper are fruits. Wisdom is knowing whether to put these in a fruit salad

    Kindly

    [1] Use code tags. Place "[code]" before the first line of code and "[/code"]" after the last line of code. Exclude quotation marks
    [2] Mark your post [SOLVED] if it has been answered satisfactorily by editing your original post in advanced mode.
    [3] Thank (using the little scale) those that provided useful help; its nice and its very well appreciated

  7. #7
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Re: Coun cells with colour and text help please

    Quote Originally Posted by ron2k_1 View Post
    This may sound a little silly, but do you have the code for the UDF installed already on your workbook?

    You need to put the code provided on a separate module.
    Nope ... I might be dumb here but what UDF?

  8. #8
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Re: Coun cells with colour and text help please

    An UDF stands for User Defined Function. It is in effect a function created by VBA code because Mr Gates didn't give it to us by default on Excel. The code for the function is at the bottom of the of the page that B.P. gave to you. Copy everything and paste in VBE:

    1. Highlight Code and copy,
    2. Go back to excel sheet
    3. Press Alt + F11
    4. Go to insert>Module
    5. Paste code,
    6. Go back to excel wb and use the function

    If you don't what colour index you used on the range, determine colour index by using the formula as stated on the first paragraph of the page.

  9. #9
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Re: Coun cells with colour and text help please

    I have copied the VBA code in and it still showed #NAME? si I deleted the formula and re-entered it.

    but still showing #NUM! when it finishes recalculating.
    Last edited by Lensmeister; 09-08-2011 at 04:24 PM.

  10. #10
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Re: Coun cells with colour and text help please

    Works for me. Select different player from C1, and you'll see that it changes. Ensure that you enable macros, and that your macro security is set to medium or lower.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Re: Coun cells with colour and text help please

    Your one did with me too..
    I need to rethink how to do this maybe.

    I am trying to calculate how many times a player has been sent off. Thing is I have over 3000 results and the teams are written as each game is a row. Hence a selection ofthe range od team being SendOffs being all the possible team line up.

    The Players are on another sheet and that calculated the players appearances with countif, but I also want to add the sending offs in to a column.

    I make the players sent off with a Red background and white text.

    I didn't want to totally rewrite the whole workbook from scratch

    I'd love to be able to get this amount of data into access and do it in that, but I like the countif function to calculate things. It's a monster spreadsheet of about 25MB

    Any suggestions?

  12. #12
    Valued Forum Contributor ron2k_1's Avatar
    Join Date
    09-30-2009
    Location
    Not the USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    606

    Re: Coun cells with colour and text help please

    The background color of the cell is the only indication you have that the player has been sent off? If you have some other indicator on another column like an "SO" or a date, or anything on another column, then you can probably use an IF combination and get a count pretty easily.

    Can you give us little mock up, cut your data set to as small as possible and tell us what your objectives are. And I'm pretty sure we can give a tip or two.

  13. #13
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Re: Coun cells with colour and text help please

    I have decided to do it a little differently.

    I have a small bit of code that allows me to crate a filter, then I can input the details on to another sheet manually. A set of countif's then do the calcs I need.

    Thanks for your help everyone

+ Reply to Thread

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