+ Reply to Thread
Results 1 to 9 of 9

Substitute letter for number

  1. #1
    Registered User
    Join Date
    11-11-2015
    Location
    Sydney, Australia
    MS-Off Ver
    15
    Posts
    2

    Substitute letter for number

    I have a roster with shifts represented by letters e.g N-night, D-day, E-evening. I would like to add a formula at the bottom of a fortnight to calculate the hours based on N=11 hours, D=8 hours, E=8 hours.

    I have used the formula below to add up the hours but it becomes a very long formula to cover each shift for each cell

    IF(S4="D",8)+IF(S4="N",11)+IF(S4="E",8)+IF(S5="D",8)+IF(S5="N",11)+IF(S5="E",8)+ etc.... until I have covered the fortnight range of cells i.e 14 cells

    Are there any shortcuts? I tried to make it a range but it did not work e.g IF(S4:18="E",8)+(S4:S18="N",11) + etc...

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Substitute letter for number

    Maybe something like this...

    =(COUNTIF(Range,"N")*11)+(COUNTIF(Range,"E")*8)+(COUNTIF(Range,"D")*8)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  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,425

    Re: Substitute letter for number

    Maybe:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS
    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
    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,425

    Re: Substitute letter for number

    Or:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards, TMS

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Substitute letter for number

    Or...

    =SUM(COUNTIF(Range,{"N","E","D"})*{11,8,8})

  6. #6
    Registered User
    Join Date
    11-11-2015
    Location
    Sydney, Australia
    MS-Off Ver
    15
    Posts
    2

    Re: Substitute letter for number

    Thank you both for your responses. They both worked perfectly! Much better than my 2,000 character formula. You've save me a huge headache.

  7. #7
    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,425

    Re: Substitute letter for number

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Substitute letter for number

    You're welcome. We appreciate the feedback!

  9. #9
    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,425

    Re: Substitute letter for number

    Or...

    =SUM(COUNTIF(Range,{"N","E","D"})*{11,8,8})
    Just showing off

+ 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. Substitute: any particular letter in string
    By daffykyle in forum Excel General
    Replies: 6
    Last Post: 05-26-2011, 09:11 AM
  2. Replies: 17
    Last Post: 07-16-2009, 03:12 AM
  3. Format:change headers from letter to number/number to letter
    By Biff in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  4. Replies: 2
    Last Post: 05-09-2005, 04:06 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