ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Currency Format for label in UserForm (https://www.excelbanter.com/excel-programming/345956-currency-format-label-userform.html)

Allen Geddes

Currency Format for label in UserForm
 
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

Allen Geddes

Currency Format for label in UserForm
 
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



"Allen Geddes" wrote:

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


Dave Peterson

Currency Format for label in UserForm
 
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?

Allen Geddes wrote:

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

"Allen Geddes" wrote:

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


--

Dave Peterson

Allen Geddes

Currency Format for label in UserForm
 
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

"Dave Peterson" wrote:

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?

Allen Geddes wrote:

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

"Allen Geddes" wrote:

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


--

Dave Peterson



All times are GMT +1. The time now is 10:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com