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 calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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,215,420
Messages
6,124,803
Members
449,190
Latest member
cindykay

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