Currency Format for label in UserForm

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to apply the currency format to a label in a UserForm with the
following code:

Private Sub UserForm_Initialize()

Me.lblBudget.Value = FormatCurrency(Me.lblBudget, "#,###,###.00")

End Sub

But every time I try to run it, I get an error that leads to the ".Value"
after lbl.budget. Should I be doing this another way? Thanks for your help!!

-Allen
 
Possibly something like:

lblBudget.Caption = Format(lblBudget.Caption, "$ #,###,###.00")

or

lblBudget.Caption = Format(CInt(lblBudget.Caption), "$ #,###,###.00")

I just can't get the syntax right!

-Allen
 
I designed a userform with a label on it. While in design mode, I put:
12345.32 in the label's caption (using the properties window.

Then this worked ok for me:

Private Sub UserForm_Initialize()
lblBudget.Caption = Format(lblBudget.Caption, "$ #,###,###.00")
End Sub

But it seems strange to me that you're changing the caption based on the
existing caption.

Is that what you really wanted?
 
You're right. I tried the same thing, and it worked for me too! So that got
me thinking, WHY wouldn't it work in my Actual UserForm, but it would in the
Test UserForm...

Well, it's all about where you place it. I had it BEFORE the line of code
where I populate the label with a number from a workbook... and nada.

But, when I move the Format to Currency line to the END of the Sub, it
worked beautifully! Thanks for your help Dave!!!

-Allen
 
Back
Top