Userform Text box Format to Currency

D

Dave M

Hello,

I have a userform that has appx. 60 textboxes. It is a form for entry of
different dollar values. Each textbox has a control source to a named range
on the excel sheet.

How can I set each textbox to a currency format when the user opens the
form?

Thanks

David Mongrain
 
P

Peter T

The short answer is you can't. Means you have to format as necessary when
done, eg

Private mCur as Currency ' at module level

Private Sub TextBox1_AfterUpdate()
Dim s as String
On Error Resume Next
s = Replace(TextBox1.Text, "$", "")
mCur = Val(Replace(TextBox1.Text, "$", ""))
mCur = Round(mCur, 2)

TextBox1.Text = Format(mCur, "$#,##0.00")
End Sub

You might want to do more than that minimum

Regards,
Peter T
 
D

Dave M

I found a way. On userform_activate, perform a loop of each contorl. If it
is a textbox, then set focus on it.

For each required textbox, have an onexit event, textbox1.value =
format(textbox1.value, "currency")


Thanks,

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top