1

I have a spreadsheet/userform combo that takes user input to calculate product pricing/percent tax/and square footage in consideration to output a total cost for flooring in one of the userform's textboxes.

My userform is calculating everything correctly, but I am trying to figure out how to format the output box so that it only displays values up to two digits past the decimal (i.e. $1.00). Currently, it displays up to four digits or more beyond the decimal (as seen in the Total Area, Tax Amount, and Final Price text boxes).

enter image description here

My userform code is as follows (I left out some non-pertinent sections that had to do with opening and closing the userform but everything that has to do with the functioning of it is there):

Public Sub SumTool()

  Dim A, B, C, D, E, F As Double
  Dim x As Double
  Dim finalSum As Double
  Dim addUp As Double
  Dim BeforePercent As Double
  Dim Prcnt As Double
  Dim percentALT As Double
  Dim percentSum As Double
  Dim i As Integer


  addUp = 0
  finalSum = 0
  BeforePercent = 0
  x = 0
  i = 0

'These are all area measurements

  A = 280
  B = 118
  C = 96
  D = 243
  E = 38
  F = 83

  Do While i < 1

'These are checks to see if checkboxes in the userform are True/False and 
'correspond to the area measurements above

    If LR.Value = True Then        
     x = x + A   
    Else
     x = x
    End If

   If BR1.Value = True Then
    x = x + B
   Else
    x = x
   End If

  If BR2.Value = True Then
   x = x + C
  Else
   x = x
  End If

  If KT.Value = True Then
   x = x + D
  Else
   x = x
  End If

 If BA.Value = True Then
  x = x + E
 Else
  x = x
 End If

 If HALL.Value = True Then
  x = x + F
 Else
  x = x
 End If

 i = i + 1

 Loop

'I have different calculations because the user has the option of 
'whether they want to include tax or not. If they do not (first option)
'no special conversions have to take place. If they do, the program has to
'take the entry and convert it from 5 or 10 to 0.05 or 0.10 and then carry
'forward with the rest of the operations

   If Me.Y.Value = False Then

     Prcnt = 0
     addUp = x
     finalSum = addUp * Me.ProductPrice.Value
     Me.FinalResultsBox.Value = finalSum
     Me.SqFtBox.Value = addUp
     Me.TaxAmountValue.Value = 0

   Else

     Prcnt = Me.SalesTaxNumber.Value
     addUp = x
     percentALT = Prcnt * 0.01
     BeforePercent = addUp * Me.ProductPrice.Value
     percentSum = percentALT * BeforePercent
     finalSum = BeforePercent + percentSum
     Me.FinalResultsBox.Value = finalSum
     Me.SqFtBox.Value = addUp
     Me.TaxAmountValue.Value = percentSum

   End If

End Sub

1 Answer 1

1

You may try something like this...

Me.FinalResultsBox.Value = Format(finalSum, "$0.00")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.