+ Reply to Thread
Results 1 to 9 of 9

How can I give a cell a numeric value based on the colour and text within them?

  1. #1
    Registered User
    Join Date
    04-27-2023
    Location
    London UK
    MS-Off Ver
    Office 365
    Posts
    4

    How can I give a cell a numeric value based on the colour and text within them?

    We work a 12 hour shift pattern so a 'D' shift is equal to 1.5 days of Annual Leave
    Every 2 months we do 2 weeks of 'D8' shifts which are equal to 1 day of Annual Leave
    The same values should apply when an employee takes sick leave.
    I would like the table on the right to auto-fill based on the inputs in the table on the left. If I fill a cell red and it has a 'D' as the text I would like that to be translated to a numeric value of 1.5 in the table on the right
    but if the cell is red and has a 'D8' as the text I would like that to be translated to a numeric value of 1.0 in the table on the right.

    Any and all help would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: How can I give a cell a numeric value based on the colour and text within them?

    Welcome to the forum.

    I am afraid that cell colouring and other formatting cannot be used as a criterion in a formula.
    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.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: How can I give a cell a numeric value based on the colour and text within them?

    There are VBA User Defined Functions (UDFs) that can be used to count colours but I suspect that they would need tweaking to take account of the shift codes. If you're not familiar with VBA, I would recommend you don't go there.

    Why not just use codes that represent the event? Say AL, AL8, SL, SL8, OT, etc. You also have other codes, like R-D and R-N that are not mentioned.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    04-27-2023
    Location
    London UK
    MS-Off Ver
    Office 365
    Posts
    4

    Re: How can I give a cell a numeric value based on the colour and text within them?

    I didn't mention anything for the R-D and R-N cells as they are just to show the Overtime for the person covering the shift. This will not affect the A/L or S/L balances. I am trying to achieve this result with minimal changes to the existing document but if needed then I believe I can get them authorised. If I were to use codes to represent the events then how could I convert those to values?

  5. #5
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,568

    Re: How can I give a cell a numeric value based on the colour and text within them?

    Perhaps the following will help:
    Represent annual events by prefixing with "A" and sick events by prefixing with "S".
    The formula for column T could be: =SUM(COUNTIFS(C5:P5,"AD")*1.5,COUNTIFS(C5:P5,"AN")*1.5,COUNTIFS(C5:P5,"AD8"))
    The formula for column W could be: =SUM(COUNTIFS(C5:P5,"SD")*1.5,COUNTIFS(C5:P5,"SN")*1.5,COUNTIFS(C5:P5,"SD8"))
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  6. #6
    Registered User
    Join Date
    04-27-2023
    Location
    London UK
    MS-Off Ver
    Office 365
    Posts
    4

    Re: How can I give a cell a numeric value based on the colour and text within them?

    Thanks for the above example! I have discussed this with management and they like the idea but have said that from a HR perspective that the data needs to only be visible to a select few.

    I have tried to hide and protect only the table but it then protects the rest of the cells within the sheet from being edited by others who don't have the password. We still need for unprivileged users to be able to edit the rota but not be able to see the output data. Is there any way to either only hide and protect the desired cells or to have a formula that outputs data so that it only appears on a separate sheet which I can then hide and protect?

  7. #7
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,568

    Re: How can I give a cell a numeric value based on the colour and text within them?

    In the attached file the output is moved to Sheet 2.
    Let us know if you have any questions.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    04-27-2023
    Location
    London UK
    MS-Off Ver
    Office 365
    Posts
    4

    Re: How can I give a cell a numeric value based on the colour and text within them?

    Thank you kindly! Didn't realise it was that easy......

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,568

    Re: How can I give a cell a numeric value based on the colour and text within them?

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

+ 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. Give value based on cell colour
    By joshwallace90 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2020, 03:31 PM
  2. [SOLVED] Changing text colour in a cell based on value or colour of another cell.
    By Jeankartel in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-15-2019, 07:16 PM
  3. [SOLVED] How to give Numeric Values to text
    By camisado821 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-03-2016, 01:20 PM
  4. Replies: 24
    Last Post: 11-10-2015, 07:27 PM
  5. Is it possible to give cell text a numeric value?
    By billybob013 in forum Excel General
    Replies: 12
    Last Post: 04-14-2015, 04:45 PM
  6. Replies: 7
    Last Post: 10-10-2013, 09:13 AM
  7. Give text a numeric value???
    By Dae in forum Excel General
    Replies: 2
    Last Post: 12-20-2010, 11:44 PM

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