+ Reply to Thread
Results 1 to 4 of 4

Help with getting variable to 2 decimal places

  1. #1
    Registered User
    Join Date
    07-10-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    41

    Help with getting variable to 2 decimal places

    I'm struggling a bit with getting the variable 'price' to 2 decimal places. I've got price set as Dim price As Single but it isn't working with just that. What am I doing wrong? I'd also like to round up the result of Range("D" & x).Value to #.99

    Also, as I'm a total rookie I'm struggling to be efficient with my coding and feel this script is a bit long winded. Is there anyway to reduce it down?

    Please Login or Register  to view this content.
    Last edited by DMacSTB; 03-11-2017 at 04:53 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,950

    Re: Help with getting variable to 2 decimal places

    price = Round((Range("R" & x).Value / divider * 1.2) / (1 - (Fee / 100)),2)
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    07-10-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Help with getting variable to 2 decimal places

    Awesome thanks very much. It appears as 2 decimal places but the value in the cell is still several decimal places. Any idea how to fix that?

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,950

    Re: Help with getting variable to 2 decimal places

    I just did a re-test with 2/3 and it shows 0.67, Also I'm not sure what
    round up the result of Range("D" & x).Value to #.99

    should return, so we would have to see a sample workbook.

+ 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. [SOLVED] variable type changing number of decimal places
    By russc2541 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-16-2014, 07:43 AM
  2. [SOLVED] Round variable to 4 decimal places
    By achidsey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-13-2014, 02:52 PM
  3. Variable Decimal Places in One Spreadsheet
    By moneal75 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-18-2012, 10:20 PM
  4. [SOLVED] Round Single Variable To 2 Decimal Places
    By nevi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-06-2012, 02:33 PM
  5. Forcing decimal places dependant on variable
    By NathM in forum Excel General
    Replies: 2
    Last Post: 05-04-2011, 05:34 PM
  6. How to change the number of decimal places in a variable cell reference...
    By kenab1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-08-2010, 01:32 PM
  7. Entering numbers with variable decimal places.
    By Jack in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-02-2005, 01:06 AM

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