Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Text Box Currency format with two decimal places

I have been trying to figure out how to format a text box so when
numbers are entered it formats it in the currency format. I got this
to work by reading several examples from a search I did on this group.
However It wont format to two decimal places.. here is an example..

Private Sub TextBox13_Change()
Dim sStr As String
sStr = Trim(TextBox13.Text)
sStr = Application.Substitute(Application. _
Substitute(sStr, ",", ""), "$", "")
If IsNumeric(sStr) Then
TextBox13.Text = Format( _
TextBox13.Text, "$###,###,###.##")
End If
End Sub

This code allows what I want.. but.. I can only enter the ones digit..
ie.. $1-$9 because it automatically puts in the . and then starts in
on the change.. so if I wanted to put in something for $15.34 It would
come out $1.53 and then wouldnt allow anymore input.

Can anyone help! Thanks!

Joe Derr
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Text Box Currency format with two decimal places

Joe

Use the AfterUpdate event instead of Change. Change runs whenever a number
is entered into the textbox, not when the whole number is entered.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

Joe Derr wrote:
I have been trying to figure out how to format a text box so when
numbers are entered it formats it in the currency format. I got this
to work by reading several examples from a search I did on this group.
However It wont format to two decimal places.. here is an example..

Private Sub TextBox13_Change()
Dim sStr As String
sStr = Trim(TextBox13.Text)
sStr = Application.Substitute(Application. _
Substitute(sStr, ",", ""), "$", "")
If IsNumeric(sStr) Then
TextBox13.Text = Format( _
TextBox13.Text, "$###,###,###.##")
End If
End Sub

This code allows what I want.. but.. I can only enter the ones digit..
ie.. $1-$9 because it automatically puts in the . and then starts in
on the change.. so if I wanted to put in something for $15.34 It would
come out $1.53 and then wouldnt allow anymore input.

Can anyone help! Thanks!

Joe Derr



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Text Box Currency format with two decimal places

Dick,

Worked like a champ, thanks! I also book marked this site, I posted
thru google groups and it ended up here.. way cool..

Again, thanks for the Tip. I will no doubt post more as I get stumped!

Joe



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Text Box Currency format with two decimal places

Joe

I don't have anything against developersdex, but you should read this

http://www.cpearson.com/excel/DirectConnect.htm

There are a lot of benefits to connecting to MS's public groups directly.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com


Joe Derr wrote:
Dick,

Worked like a champ, thanks! I also book marked this site, I posted
thru google groups and it ended up here.. way cool..

Again, thanks for the Tip. I will no doubt post more as I get stumped!

Joe



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



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
worksheet is set up for 2 decimal places but format changes JT Spitz Excel Discussion (Misc queries) 2 September 8th 09 10:11 PM
format issues with decimal places Craig Upton Excel Discussion (Misc queries) 1 July 9th 08 07:51 PM
decimal places in format cell tom Excel Discussion (Misc queries) 2 February 16th 07 09:07 PM
Can you set to default the # of decimal places in Format Cells? Amy Setting up and Configuration of Excel 4 March 29th 06 05:08 PM
Formula for: Format Decimal places? nastech Excel Discussion (Misc queries) 16 November 4th 05 02:25 PM


All times are GMT +1. The time now is 02:13 PM.

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

About Us

"It's about Microsoft Excel"