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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
Re: Formatting UserForm to Show Dollar Sign - No Control Sou

Probably because the TxtAvgUnitPrice textbox is empty when you initialize the form ?
 

martinee

Well-known Member
Joined
Nov 4, 2003
Messages
960
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.
 

Forum statistics

Threads
1,148,528
Messages
5,747,221
Members
424,069
Latest member
kamkwok1hh

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
Top