+ Reply to Thread
Results 1 to 7 of 7

How to Make Decimal Places Automatic

  1. #1
    Registered User
    Join Date
    09-20-2012
    Location
    La Crosse, WI
    MS-Off Ver
    Excel 2010
    Posts
    70

    How to Make Decimal Places Automatic

    Is there a way to have the number of decimal places in a list of cells automatically generate depending on the number of decimal places given in another cell? It's a difficult question to explain but attached is a document showing what i would need...can the cells J8:M8 automatically generate the same number of decimal places as cell C8, and this would need to generate in the same way for every row after . The number of decimal places are dependant on the number given in column C...
    Inspection Report - Formatting Project Master Copy.xlsx
    Regards,
    Cansa

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How to Make Decimal Places Automatic

    It can be done with a a macro. Are you o.k. with macros?
    Gary's Student

  3. #3
    Registered User
    Join Date
    09-20-2012
    Location
    La Crosse, WI
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: How to Make Decimal Places Automatic

    I am a-okay with Macros

    Cansa

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How to Make Decimal Places Automatic

    Install the following event macro in the worksheet code area:

    Please Login or Register  to view this content.
    You need to:
    1. select a cell in column C
    2. set the format
    3. enter a value



    Because it is worksheet code, it is very easy to install and automatic to use:

    1. right-click the tab name near the bottom of the Excel window
    2. select View Code - this brings up a VBE window
    3. paste the stuff in and close the VBE window

    If you have any concerns, first try it on a trial worksheet.

    If you save the workbook, the macro will be saved with it.


    To remove the macro:

    1. bring up the VBE windows as above
    2. clear the code out
    3. close the VBE window

    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    To learn more about Event Macros (worksheet code), see:

    http://www.mvps.org/dmcritchie/excel/event.htm

  5. #5
    Registered User
    Join Date
    09-20-2012
    Location
    La Crosse, WI
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: How to Make Decimal Places Automatic

    Thank you Gary's Student, I am more and more amazed with what macros can do and your help was great!

    Cansa

  6. #6
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How to Make Decimal Places Automatic

    Thanks for the feedback!

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to Make Decimal Places Automatic

    FYI, a non-macro solution
    1. Convert Col C to Text
    2. Select F8:M29 > Conditional Formatting> New Rule > Use Formula
    =LEN($C8)-SEARCH(".",$C8)=1 Formatting> Number> Number and set decimals to 1
    3. Repeat Step 2 with formula = 2 for 2 decimals, 3 for 3, etc.
    See attached.
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ 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