+ Reply to Thread
Results 1 to 12 of 12

How do I display a number as both a decimal and a fraction?

  1. #1
    Registered User
    Join Date
    05-09-2019
    Location
    MA
    MS-Off Ver
    Excel 2013 on Windows 10 Pro
    Posts
    8

    Question How do I display a number as both a decimal and a fraction?

    I would like to somehow create a cell format or macro\VBA where when I type in my dimension in inches into the cell, such as 1.75, that is displays BOTH the fraction and decimal.

    Example. Type 1.75 into cell A1 hit enter
    A1 Displays: 1 3/4" (1.75")

    I'd like the fraction to show first and the decimal to show in parenthesis ( ). The cell format for the first step would be: # ??/??\", but I am not sure how to get it to read the second part with the decimals.

    Anyone know how to do this? I am not familiar with coding, macros or VBA, so any step by step instructions would be extremely helpful.

    I am really good with formulas and embedding multiple formulas into one another, but I cant seem to find anything that will work for this kind of scenario, which is why I am thinking of a macro or VBA.

    Thank you
    Debbie
    Last edited by Richard Buttrey; 05-09-2019 at 11:17 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hello - New to this Forum - Need Help with Macros and VBA

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    Since you're new here I'll change then title for you but not for the future.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Valued Forum Contributor
    Join Date
    01-07-2013
    Location
    Michigan
    MS-Off Ver
    O365
    Posts
    601

    Re: How do I display a number as both a decimal and a fraction?

    Check out this post by shg for a potential solution. It's a good start toward a solution. Here's a modified version that adds the decimal portion in parentheses:
    Please Login or Register  to view this content.
    Please note this is relatively untested. All credit to shg for the formula.

    Edit: Did not understand that this should be a single cell solution. Leaving formula in case it's useful.
    Last edited by Melvosh; 05-09-2019 at 11:31 AM.
    If someone helped achieve your solution, consider clicking "* Add Reputation" on their post.

    If your question has been answered, mark the thread as [SOLVED] using the Thread Tools menu at the top of the thread.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I display a number as both a decimal and a fraction?

    Hi,

    You can Format a cell like 1.75 as a Fraction and see it presented as 1 3/4
    I don't believe you can format it to show BOTH the original decimal and a fraction. You'd have to have the decimal version in another cell pointing to the original number and formatted as a number.

  5. #5
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Re: How do I display a number as both a decimal and a fraction?

    I'm not sure if this will work for you, but you could, for example, enter 1 3/4" in cell D6, and 1.75 in cell E6, and bring them together in cell F6 with the following formula:
    Please Login or Register  to view this content.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,855

    Re: How do I display a number as both a decimal and a fraction?

    the other thing I would note is that shg's formula results in a text string -- which is not exactly the same as a formatted number.

    Does it have to be in the same cell? The way I might do this is to enter 1.75 in one cell (A1). The adjacent cell immediately to the right (B1) could be =A1. A1 is formatted as ? ??/?? and B1 is formatted as (General) and left aligned (maybe other cell formatting), so the two values are clearly together.

    It is up to you how important it is to keep the number as a number or to convert to a text string.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  7. #7
    Registered User
    Join Date
    05-09-2019
    Location
    MA
    MS-Off Ver
    Excel 2013 on Windows 10 Pro
    Posts
    8
    Thank you to the Admin, i am new and didn't fully understand, but i will be sure to check for those mistakes before submitting in t he e future.

    To everyone, yes it has to be in the same cell, I'm an engineer for a Manufacturing plant and i can't modify the template to add more columns so i need a way where i plug in the data it will format to show both fractions and decimals. If i use shg formula, how would i do that? If a formula is in the cell and i type my lengths, won't that just override my formulas?

  8. #8
    Valued Forum Contributor
    Join Date
    01-07-2013
    Location
    Michigan
    MS-Off Ver
    O365
    Posts
    601
    A formula would require another cell. I don't think there's any way to show the same value formatted multiple ways in the same cell.

  9. #9
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,855

    Re: How do I display a number as both a decimal and a fraction?

    I agree with Melvosh -- there is no way to have both a formula and enter values into a cell.

    If I were in this situation, I would probably have a helper range (maybe even in a separate file if I was not allowed to use a range in the template file). I would enter my values in the left column and have that formula in the right column. After entering my values, then I would select the second column -> copy -> select the column in the template file -> paste special -> as values. Be sure to remember that this converts the number 1.75 to the text string "1 3/4 (1.75)" which is not usable in other calculations. =2*"1 3/4 (1.75)" will return an error because Excel does not know how to use that text string as a number. I think this is how I would do it if I was not allowed to make any changes to the file (other than data entry and number formatting).

    If you are not allowed to so much as add a column to the template file, then you probably also cannot add a change event macro. For completeness' sake, I will mention that one could conceivably have a change event macro that will detect when you enter a value in this column -- read the value entered -- convert to the desired text string -- write the text back into the modified cell. Again, if you are not allowed to add any columns, I doubt you are allowed to add a macro to the file, either. Just in case -- something like that can work.

    I could see this becoming very tedious in the long run. I might talk to the author/controller of the file and lobby them to either make some changes to the file or allow you to make a few changes. If they just won't budge, I think I would keep a small file on hand with shg's formula to use as a data entry file, then copy and paste as values into the real file.

  10. #10
    Registered User
    Join Date
    05-09-2019
    Location
    MA
    MS-Off Ver
    Excel 2013 on Windows 10 Pro
    Posts
    8

    Re: How do I display a number as both a decimal and a fraction?

    I can add macros, but I am not familiar with developing them. We have three manufacturing facilities and they want to keep the excel format\template consistent between the three plants but as far as modifying cell formats, etc. we are allowed to do that based on our plant's need. I have a need to show in some instances the decimal and fraction and then later on we might want to look in other areas showing metric and standard, but that's for a later discussion and thread for the future, but I might be able to figure out that macro on my own if I get help with this one first.

  11. #11
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,855

    Re: How do I display a number as both a decimal and a fraction?

    This tutorial talks about change event procedures: https://www.excelanytime.com/excel/i...=79&Itemid=475 If you work your way through the tutorial, you should get to their "Error Handler example 1" and "error handler example 2" examples -- which are pretty close to what I would expect for your code. In their examples, the code checks if A1 or B1 are the changed cell (if yes then exit). If any other cell in column 1 or 2 is changed and the value entered is a number, then it will add 1 to B2. In your case, instead of adding 1 to B2, you will be reading the changed value, converting it to the text string as noted above, then writing that back into the changed cell.
    Please Login or Register  to view this content.
    When you decide to implement the unit conversion, that should also fit in the same skeleton -- instead of just concatenating the two formats, your code will need to perform the unit conversion then concatenate the results (or whatever your desired output format will be). There are a lot of change event examples on this forum and around the internet. Most of them use a skeleton very similar to the one in this tutorial. If you are allowed to add a macro to the file, that may be the easiest way to simplify your data entry.

    VBA Format function help file: https://docs.microsoft.com/en-us/off...r-applications

  12. #12
    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: How do I display a number as both a decimal and a fraction?

    A
    B
    C
    1
    Value
    Presentation
    2
    1.3125
    1.3125 (1 5/16) B2: =A2 & TEXT(A2, " (? ??/??)")
    3
    2.25
    2.25 (2 1/4 )
    4
    2.625
    2.625 (2 5/8 )
    5
    3.75
    3.75 (3 3/4 )
    6
    4.625
    4.625 (4 5/8 )
    Entia non sunt multiplicanda sine necessitate

+ 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. Hello - New to this Forum
    By DBasque in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 05-09-2019, 11:13 AM
  2. Seraching new ports without Programming/VBA/Macros Forum?
    By bebo021999 in forum The Water Cooler
    Replies: 2
    Last Post: 02-14-2015, 05:21 PM
  3. sorry new to forum mac wont run macros built in office 2010
    By vinceyboy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2013, 01:06 AM
  4. New to this forum, with Lots of MACROS Doubts
    By Kiran222 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 12-05-2012, 01:40 AM
  5. Replies: 1
    Last Post: 11-20-2012, 06:54 AM
  6. Replies: 22
    Last Post: 10-31-2012, 01:29 PM
  7. Running Macros Truly the best forum in the world
    By khalid79m in forum Excel General
    Replies: 4
    Last Post: 03-17-2007, 02:34 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