I am using a user form to display calculations made using data from a spreadsheet. The code I have written produces the intended result, except I am having trouble figuring out how to format the output to the correct number of decimal places. For example, I would like the value for CalcGmb to display to three decimal places e.g. "0.000", but instead it displays as "0.000000". So far, the standard method to format the cell number format like NumberFormat = "0.000" has not worked. Hopefully someone has some ideas on how to make this work. Thank you in advance for your assistance.
Sub test()
'
' Defines the variables
'
Dim JMFGmm As Single
Dim JMFGmb As Single
Dim JMFVa As Single
Dim JMFVMA As Single
Dim JMFVFB As Single
Dim JMFUW As Single
Dim CalcGmm As Single
Dim CalcGmb As Single
Dim CalcVa As Single
Dim CalcVMA As Single
Dim CalcVFB As Single
Dim CalcUW As Single
Dim CalcDPE As Single
'
' Defines the JMF Values on the userform
'
JMFGmm = Range("G55")
JMFGmb = JMFGmm * 0.96
JMFVa = Range("K55")
JMFVMA = Range("M55")
JMFVFB = Range("O55")
JMFUW = Range("Q55")
'
' Calculates the volumetrics based on the data in the spreadsheet
'
CalcGmm = 100 / (((100 - Range("D55")) / Range("I47")) + (Range("D55") / Range("U12")))
CalcGmb = CalcGmm * 0.96
CalcVa = ((CalcGmm - CalcGmb) / CalcGmm) * 100
CalcVMA = 100 - ((100 - Range("D55")) * CalcGmb) / Range("W43")
CalcVFB = ((CalcVMA - CalcVa) / CalcVMA) * 100
CalcUW = CalcGmb * 997.3
CalcDPE = Range("W41") / (Range("D55") - (((100 * Range("U12") * ((Range("I47") - Range("W43")) / _
(Range("I47") * Range("W43"))))) / 100) * (100 - Range("D55")))
'
' Displays the cell data and calculations on the userform
'
Mix_Properties.JMFGmm = JMFGmm
Mix_Properties.JMFGmb = JMFGmb
Mix_Properties.JMFVa = JMFVa
Mix_Properties.JMFVMA = JMFVMA
Mix_Properties.JMFVFB = JMFVFB
Mix_Properties.JMFUW = JMFUW
Mix_Properties.CalcGmm = CalcGmm
Mix_Properties.CalcGmb = CalcGmb
Mix_Properties.CalcVa = CalcVa
Mix_Properties.CalcVMA = CalcVMA
Mix_Properties.CalcVFB = CalcVFB
Mix_Properties.CalcUW = CalcUW
Mix_Properties.CalcDPE = CalcDPE
'
' Shows the userform the data
'
Mix_Properties.Show vbModeless
'
Application.ScreenUpdating = True
'
End Sub
Sub test()
'
' Defines the variables
'
Dim JMFGmm As Single
Dim JMFGmb As Single
Dim JMFVa As Single
Dim JMFVMA As Single
Dim JMFVFB As Single
Dim JMFUW As Single
Dim CalcGmm As Single
Dim CalcGmb As Single
Dim CalcVa As Single
Dim CalcVMA As Single
Dim CalcVFB As Single
Dim CalcUW As Single
Dim CalcDPE As Single
'
' Defines the JMF Values on the userform
'
JMFGmm = Range("G55")
JMFGmb = JMFGmm * 0.96
JMFVa = Range("K55")
JMFVMA = Range("M55")
JMFVFB = Range("O55")
JMFUW = Range("Q55")
'
' Calculates the volumetrics based on the data in the spreadsheet
'
CalcGmm = 100 / (((100 - Range("D55")) / Range("I47")) + (Range("D55") / Range("U12")))
CalcGmb = CalcGmm * 0.96
CalcVa = ((CalcGmm - CalcGmb) / CalcGmm) * 100
CalcVMA = 100 - ((100 - Range("D55")) * CalcGmb) / Range("W43")
CalcVFB = ((CalcVMA - CalcVa) / CalcVMA) * 100
CalcUW = CalcGmb * 997.3
CalcDPE = Range("W41") / (Range("D55") - (((100 * Range("U12") * ((Range("I47") - Range("W43")) / _
(Range("I47") * Range("W43"))))) / 100) * (100 - Range("D55")))
'
' Displays the cell data and calculations on the userform
'
Mix_Properties.JMFGmm = JMFGmm
Mix_Properties.JMFGmb = JMFGmb
Mix_Properties.JMFVa = JMFVa
Mix_Properties.JMFVMA = JMFVMA
Mix_Properties.JMFVFB = JMFVFB
Mix_Properties.JMFUW = JMFUW
Mix_Properties.CalcGmm = CalcGmm
Mix_Properties.CalcGmb = CalcGmb
Mix_Properties.CalcVa = CalcVa
Mix_Properties.CalcVMA = CalcVMA
Mix_Properties.CalcVFB = CalcVFB
Mix_Properties.CalcUW = CalcUW
Mix_Properties.CalcDPE = CalcDPE
'
' Shows the userform the data
'
Mix_Properties.Show vbModeless
'
Application.ScreenUpdating = True
'
End Sub