+ Reply to Thread
Results 1 to 8 of 8

Insert Hyphen

  1. #1
    Registered User
    Join Date
    02-20-2011
    Location
    Queensland, Australia
    MS-Off Ver
    Office 365
    Posts
    71

    Insert Hyphen

    Random data (inches) is entered into A1 of the attached spreadsheet, and the formula in A2 returns feet & inches.

    How can I separate whole inches & and fractions of remaining inches (if any) with a hyphen, so that say…

    • 1’ 1 11/16” becomes
    • 1’ 1-11/16”

    mgs
    Attached Files Attached Files
    Last edited by mgs; 02-11-2013 at 05:32 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Insert Hyphen

    try "# - #/##
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    02-20-2011
    Location
    Queensland, Australia
    MS-Off Ver
    Office 365
    Posts
    71

    Re: Insert Hyphen

    "Excellent - it works!"

    Thanks very much.

    mgs

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Insert Hyphen

    Happy to help. If this answered your question, please take a moment to mark the thread as "solved" - it helps keep things neet and tidy lol, and consider adding the reputation to those that helped (see points 2 & 3 below)

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Insert Hyphen

    Another way:

    = TEXT(INT(A1/12), "0' ;;")
    & INT(MOD(A1, 12))
    & IF(MROUND(MOD(A1, 1), 1/16), TEXT(MROUND(MOD(A1, 1), 1/16), "-?/??"), "")
    & """"
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    02-20-2011
    Location
    Queensland, Australia
    MS-Off Ver
    Office 365
    Posts
    71

    Re: Insert Hyphen

    Thanks shg, yours is shorter so therefore better.
    mgs

    P.S. AND more accurate!
    mgs
    Last edited by mgs; 02-11-2013 at 07:12 PM.

  7. #7
    Registered User
    Join Date
    02-20-2011
    Location
    Queensland, Australia
    MS-Off Ver
    Office 365
    Posts
    71

    Re: Insert Hyphen

    Thanks FDibbins, have done that.
    mgs

  8. #8
    Registered User
    Join Date
    02-20-2011
    Location
    Queensland, Australia
    MS-Off Ver
    Office 365
    Posts
    71

    Re: Insert Hyphen

    Quote Originally Posted by shg View Post
    Another way:

    = TEXT(INT(A1/12), "0' ;;")
    & INT(MOD(A1, 12))
    & IF(MROUND(MOD(A1, 1), 1/16), TEXT(MROUND(MOD(A1, 1), 1/16), "-?/??"), "")
    & """"
    Hi shg,
    I used your formula for a while, until Dr. Google found this one for me (it is long-winded, but it is exactly what I was originally looking for...):

    =IF(A1<0,"("," ")&IF(TRUNC(ROUND(ABS(A1)*16,0)/16/12,0)<1,"",TRUNC(ROUND(ABS(A1)*16,0)/16/12,0)&"'"&IF(MOD(ABS(A1),12)=0,""," "))&IF(TRUNC(ROUND(ABS(A1)*16,0)/16-12*TRUNC(ROUND(ABS(A1)*16,0)/16/12,0))>=1,TRUNC(ROUND(ABS(A1)*16,0)/16-12*TRUNC(ROUND(ABS(A1)*16,0)/16/12,0))&IF(MOD(ABS(A1),1)=0,"","-"),"")&IF(MOD(A1,1)=0,"",ROUND(MOD(ABS(A1),1)*16,0)/GCD(ROUND(MOD(ABS(A1),1)*16,0),16)&"/"&16/GCD(ROUND(ABS(A1)*16,0),16))&IF(MOD(ABS(A1),12)=0,"","""")&IF(A1<0,")"," ")

    Cheers,
    mgs

+ 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