Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default Currency format for combo box in a user form

Hi,
I have a combo box on a user form and when someone types the price, say 60 I
want it to be displayed as $60.00 not 60. Can anyone help? Thank you in
advance.
--
Though daily learning, I LOVE EXCEL!
Jennifer
  #2   Report Post  
Posted to microsoft.public.excel.programming
Kro Kro is offline
external usenet poster
 
Posts: 7
Default Currency format for combo box in a user form

Try this:
comboboxname.value=FormatCurrency(conboboxname,0)

"Jennifer" wrote:

Hi,
I have a combo box on a user form and when someone types the price, say 60 I
want it to be displayed as $60.00 not 60. Can anyone help? Thank you in
advance.
--
Though daily learning, I LOVE EXCEL!
Jennifer

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default Currency format for combo box in a user form

I tried this and I am getting a yellow error line:
1st: I miss spoke it is a text box
2nd: I put the following in the UserForm Initialize syntax, is this correct?

Me.txtPrice.Value = FormatCurrency(Me.txtPrice, 0)

"Kro" wrote:

Try this:
comboboxname.value=FormatCurrency(conboboxname,0)

"Jennifer" wrote:

Hi,
I have a combo box on a user form and when someone types the price, say 60 I
want it to be displayed as $60.00 not 60. Can anyone help? Thank you in
advance.
--
Though daily learning, I LOVE EXCEL!
Jennifer

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Currency format for combo box in a user form

Hi Jennifer,

(1) you need to select a format to apply to the currency : for example,
if you want the currency to be formatted as : 1,234.56, then your code
should be :
Me.txtPrice.Value = FormatCurrency(Me.txtPrice, "#,###,###.00")

(2) the code above does not apply a permanent format to the text box,
instead it just modifies the string inside the text box.

(3) move the code from the initialize procedure to the textbox Enter
and Exit procedures to get a consistent currency format:
Private Sub txtPrice_Enter()
txtPrice.Value = Format(Me.txtPrice.Value, "")
End Sub

Private Sub txtPrice_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtPrice.Value = Format(Me.txtPrice.Value, "#,###,###.00")
End Sub

this automatically modifies the format of the text box as soon as it
loses focus, and automatically formats it back to an "editable" format
when you enter the text box again.

HTH

Fadi
www.chalouhis.com/XLBLOG

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default Currency format for combo box in a user form

Thank you, it works great! Thank you also for explaining it so clearly, very
helpful.
Regards,
Jennifer

"Fadi Chalouhi" wrote:

Hi Jennifer,

(1) you need to select a format to apply to the currency : for example,
if you want the currency to be formatted as : 1,234.56, then your code
should be :
Me.txtPrice.Value = FormatCurrency(Me.txtPrice, "#,###,###.00")

(2) the code above does not apply a permanent format to the text box,
instead it just modifies the string inside the text box.

(3) move the code from the initialize procedure to the textbox Enter
and Exit procedures to get a consistent currency format:
Private Sub txtPrice_Enter()
txtPrice.Value = Format(Me.txtPrice.Value, "")
End Sub

Private Sub txtPrice_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtPrice.Value = Format(Me.txtPrice.Value, "#,###,###.00")
End Sub

this automatically modifies the format of the text box as soon as it
loses focus, and automatically formats it back to an "editable" format
when you enter the text box again.

HTH

Fadi
www.chalouhis.com/XLBLOG


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding items to a combo box on a user form Gazz_85[_2_] Excel Discussion (Misc queries) 1 July 9th 09 05:00 PM
Date format changes when inputed from user form Lynz Excel Discussion (Misc queries) 16 December 13th 08 11:27 PM
How do I hide zero values but keep currency format in P.O. form? Mamarita New Users to Excel 4 February 9th 06 11:53 PM
Patrick -- 424 Combo Box User Form Jennifer Excel Programming 2 April 8th 05 07:31 AM
Run Time Error 424 Combo Box User Form Jennifer Excel Programming 3 April 7th 05 08:23 PM


All times are GMT +1. The time now is 12:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"