Formatting For UserForm Label Not Working

marsow

New Member
Joined
Jan 30, 2015
Messages
28
Hi everyone,


The code here works. But, I can never get the value (displayed in a userform label) to be formatted numerically with commas and 2 decimals (e.g. 1,500.00). I tried every code and placed it everywhere but fails everytime. A simple addition of 1000 + 1500 equals 2001.00. :( I don't know what else to do and it's been so long now. I would appreciate some help, please.

NewRetailAmt = Me.tbx_rtlamt.Value * Me.tbx_Qty.Value
lbl_sbtot.Caption = Val(lbl_sbtot.Caption) + NewRetailAmt

Legend:
NewRetailAmt - is a variable
tbx_rtlamt - textbox with numeric input
tbx_Qty - textbox with numeric input as multiplier
lbl_sbtot - label to display sum

I tried these lines of code with no luck:
'Me.lbl_sbtot.Value = Format(Me.lbl_sbtot, "#,##0.00")
Or
'lbl_sbtot = Format(lbl_sbtot, "Standard")

Best regards, -m.
 
Last edited:
.
You are welcome.

The only reason it took so much thought is because my brain doesn't work as well as it did decades ago.

:LOL:
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
I know I'm an idiot at this but I still need help. :) Where in the code do I place it in the userform module?

Sub SalesForm()
SalesForm1.Show

Private Sub UserForm_Initialize()
ActiveSheet.Range("S1108").Value = "$1.00"
tbx_tamt.Text = ActiveSheet.Range("S1108").Value
End Sub


Private Sub cmbtn_sbmt_Click()
Dim ans As String
Dim totl As String
ans = (tbx_rtlamt.Text * tbx_Qty.Text)
totl = Format(ans, "Currency") + ActiveSheet.Range("S1108").Value
Label1.Caption = Format(totl, "Currency")
End Sub
 
Upvote 0
Hi Logit,

Thanks again for the sample workbook and working code. I just added a line to make the code add to the calculation each button click.

ans = (TextBox1.Text * TextBox2.Text)
totl = Format(ans, "Currency") + ActiveSheet.Range("A1").Value


Range("A1").Value = totl


Label1.Caption = Format(totl, "Currency")

Best regards, - m
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,679
Members
449,463
Latest member
Jojomen56

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