+ Reply to Thread
Results 1 to 3 of 3

Custom Text with Formula

  1. #1
    Registered User
    Join Date
    06-01-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel:Mac 2003
    Posts
    1

    Custom Text with Formula

    Im trying to do the schedule at work, and what I want is:
    (attached is a picture of the cells)

    To be able to enter '4:00 PM' into cell B4, and have it show up as 'CL', but do the formula as if I had entered '4:00 PM', giving me the difference in hours in cell C4.

    But if I enter any other number than '4:00 PM', I do not want 'CL' to show up.

    How can I make this work?
    Thanks
    Attached Images Attached Images

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Custom Text with Formula trouble.

    This might prove difficult given roundings involved with Time but you might find you can highlight the A:B range and apply a Custom Format to said cells of:

    [>=0.66667]h:mm AM/PM;[<=0.666665]h:mm AM/PM;"CL"

    Assuming you're only entering values to the second (or minute) you should find that only 4:00 PM appears in-cell as "CL"

    In terms of C4:

    =MOD(B4-A4,1)*24
    copied down

    (remove the *24 if you wish for the resulting value to be stored as a true Time value (ie 4:30) as opposed to decimal hours (4.5))

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Custom Text with Formula trouble.

    You should be typing CL directly into cell B4.

    Your formula in C4 will have to watch for that and and deal with it accordingly.

    =IF(B4="CL", "6:00 PM" - A4, B4 - A4) * 24
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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