Formatting UserForm to Show Dollar Sign - No Control Source

Simba1

Board Regular
Joined
Dec 13, 2004
Messages
165
Hi guys,

I was searching through the archives to help me with a userform problem I was having. It seems as though a few other people had similar problems, but I can't get this to work. All I want to do is have my UserForm show dollar signs on the form.

The code I've been using, and fiddling with is:

Private Sub UserForm_Initialize()
TxtAvgUnitPrice.Text = Format(TxtAvgUnitPrice.Value, "$#,##")
End Sub

-I am not using a Control Source, if this makes it any easier to explain why I'm not getting the result I want.

Can anyone help with this?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Re: Formatting UserForm to Show Dollar Sign - No Control Sou

Probably because the TxtAvgUnitPrice textbox is empty when you initialize the form ?
 
Upvote 0
Re: Formatting UserForm to Show Dollar Sign - No Control Sou

Two basic options, the first just uses a label out in front, the second implements some code: (See Below)
form.gif

Code:
Private Sub TextBox2_Change()
If InStr(1, TextBox2.Text, "$") = 0 Then
TextBox2.Text = "$" & TextBox2.Text
End If
End Sub
This would be in the UserForm module. HTH.
 
Upvote 0

Forum statistics

Threads
1,222,404
Messages
6,165,856
Members
451,987
Latest member
Johnzdz

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