Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Help
I have created a couple userform the calculate a formula,
based on inputed info from the user. In certain situations the answer needs to be a Dollar value and in others the calculated number only needs to display 4 numbers past the decimal point. How do I cange this code to reflect the two seperate situations. Private Sub CommandButton1_Click() sStr = "#" & Trim(TextBox1) & "#" & Trim(TextBox2) & "#" & _ Trim(TextBox3) & "#" & Trim(TextBox4) & "#" sStr1 = Application.Substitute(Application.Substitute (sStr, "#", ""), ".", "") If InStr(sStr, "##") = 0 And IsNumeric(sStr1) Then TextBox5 = (CDbl(TextBox1) * CDbl(TextBox2)) / (CDbl (TextBox3) * CDbl(TextBox4) * 12) End If End Sub Any help is better than what I got. Thanks Pete W |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Help
dblVal = (CDbl(TextBox1) * CDbl(TextBox2)) / _
(CDbl(TextBox3) * CDbl(TextBox4) * 12) TextBox5 = Format(dblVal,"$ #,##0") or Textbox4 = Format(dblVal,"0.0000") -- Regards, Tom Ogilvy "Pete" wrote in message ... I have created a couple userform the calculate a formula, based on inputed info from the user. In certain situations the answer needs to be a Dollar value and in others the calculated number only needs to display 4 numbers past the decimal point. How do I cange this code to reflect the two seperate situations. Private Sub CommandButton1_Click() sStr = "#" & Trim(TextBox1) & "#" & Trim(TextBox2) & "#" & _ Trim(TextBox3) & "#" & Trim(TextBox4) & "#" sStr1 = Application.Substitute(Application.Substitute (sStr, "#", ""), ".", "") If InStr(sStr, "##") = 0 And IsNumeric(sStr1) Then TextBox5 = (CDbl(TextBox1) * CDbl(TextBox2)) / (CDbl (TextBox3) * CDbl(TextBox4) * 12) End If End Sub Any help is better than what I got. Thanks Pete W |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VBA userform | Excel Worksheet Functions | |||
userform | New Users to Excel | |||
userform | Excel Programming | |||
userform | Excel Programming | |||
Userform help | Excel Programming |