Can someone tell me how to leave the number with only 4 decimal places?

KhallP

Board Regular
Joined
Mar 30, 2021
Messages
157
Office Version
  1. 2016
Platform
  1. Windows
The "error":

provas.JPG



The code:
Code:
    Dim oPL As Double, o709 As Double, o710 As Double, o713 As Double
    Application.ScreenUpdating = False
    Sheets("Calculation_Sheet").Visible = True

    ActiveWorkbook.Sheets("calculation_sheet").Activate

Note: P666, P709, P710 and P713 are global variables
Code:
    Range("B18").Select
    ActiveCell = A_90
    Range("B26").Select
    ActiveCell = A0
    Range("B33").Select
    ActiveCell = A90
      
    Range("I6").Select
    oPL = ActiveCell.Value
    Range("I7").Select
    o709 = ActiveCell.Value
    Range("I8").Select
    o710 = ActiveCell.Value
    Range("I9").Select
    o713 = ActiveCell.Value
  
    oPL = Format(oPL, "0.####")
    o709 = Format(o709, "0.####")
    o710 = Format(o710, "0.####")
    o713 = Format(o713, "0.####")
  
    Range("J6").Select
    P666 = ActiveCell.Value
    Range("J7").Select
    P709 = ActiveCell.Value
    Range("J8").Select
    P710 = ActiveCell.Value
    Range("J9").Select
    P713 = ActiveCell.Value
  
    P666 = Format(P666, "0.####")
    P709 = Format(P709, "0.####")
    P710 = Format(P710, "0.####")
    P713 = Format(P713, "0.####")
  
    out_666.Value = P666
    out_709.Value = P709
    out_710.Value = P710
    out_713.Value = P713
 
Last edited by a moderator:
As giving a sample for a value and its expected result is at kid level and has nothing to do with privacy !​
So as I'm a very beginner to guess anything maybe someone else may help …​
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
As giving a sample for a value and its expected result is at kid level and has nothing to do with privacy !​
So as I'm a very beginner to guess anything maybe someone else may help …​
I literally said that the value would have to have a comma between 3 and 1 as in the example xD
 
Upvote 0
How About:
VBA Code:
oPL = Format(oPL, "#,###.0000")
OR
VBA Code:
oPL = Format(oPL - Int(oPL/1), "#,###.0000")
 
Upvote 0
It seems to me that the remaining of your decimal number is hidden from view due to the width of your text box. How about trying to increase the with of your text box a bit. :LOL:
 
Upvote 0
It seems to me that the remaining of your decimal number is hidden from view due to the width of your text box. How about trying to increase the with of your text box a bit. :LOL:
I don't think you understand anything about the post
 
Upvote 0
According to your last pictures as I yet wrote you use a bad arithmetic logic !​
As any kid can solve this just by dividing first the number …​
 
Upvote 0

Forum statistics

Threads
1,216,211
Messages
6,129,528
Members
449,515
Latest member
lukaderanged

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top