Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Textbox formatting

Hey guys,

I still cannot get a $ sign to come up before everything I type in a
textbox.


I want to be able to type in lets say TextBox1 and when I do, the $ sign
pops up in front of the number. I need the dollar sign to always be there
no matter how many times I re-enter numbers and I need it to format the cell
as $0.00


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Textbox formatting

Todd,

Try something like the following:

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Left(Me.TextBox1.Text, 1) < "$" Then
Me.TextBox1.Text = "$" & Me.TextBox1.Text
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Todd Huttenstine" wrote in message
...
Hey guys,

I still cannot get a $ sign to come up before everything I type

in a
textbox.


I want to be able to type in lets say TextBox1 and when I do,

the $ sign
pops up in front of the number. I need the dollar sign to

always be there
no matter how many times I re-enter numbers and I need it to

format the cell
as $0.00




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Textbox formatting

You can certainly add more checking to this, but basically (if I understand
the question) you can approach it like this:

Private Sub Textbox1_Change()
sStr = TextBox1.Text
If InStr(sStr, ".") Then
TextBox1.Text = _
Format(CDbl(Application.Substitute( _
TextBox1, "$", "")), "$ #.##")
Else
TextBox1.Text = _
Format(CDbl(Application.Substitute( _
sStr, "#$", "")), "$ #")
End If
End Sub


--
Regards,
Tom Ogilvy


Todd Huttenstine wrote in message
...
Hey guys,

I still cannot get a $ sign to come up before everything I type in a
textbox.


I want to be able to type in lets say TextBox1 and when I do, the $ sign
pops up in front of the number. I need the dollar sign to always be there
no matter how many times I re-enter numbers and I need it to format the

cell
as $0.00




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Textbox formatting

Todd,

This was previously suggested to you, and it works great for me.

Private Sub TextBox1_Enter()
TextBox1.Value = "$"
End Sub

Have you tried it?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine" wrote in message
...
Hey guys,

I still cannot get a $ sign to come up before everything I type in a
textbox.


I want to be able to type in lets say TextBox1 and when I do, the $ sign
pops up in front of the number. I need the dollar sign to always be there
no matter how many times I re-enter numbers and I need it to format the

cell
as $0.00




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Textbox formatting

The if statements worked well and I put it in the change event. Now it
works great. Thank you both.

Todd

"Todd Huttenstine" wrote in message
...
Hey guys,

I still cannot get a $ sign to come up before everything I type in a
textbox.


I want to be able to type in lets say TextBox1 and when I do, the $ sign
pops up in front of the number. I need the dollar sign to always be there
no matter how many times I re-enter numbers and I need it to format the

cell
as $0.00






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Textbox formatting

Hey Bob,

That code suggested worked initially when I entered the textbox, however if
I deleted the value in the textbox and then put in another number, it would
not put the $ sign because the code is located in the ENTER event. So I put
the same code in the CHANGE event and it put a huge long string of $ signs
in the textbox. So I needed an if statement to test if there is a $ sign.
Now when I put the following code with the IF statement in the CHANGE event,
it works.
I ended up using:

If Left(Me.TextBox12.Text, 1) < "$" Then
Me.TextBox12.Text = "$" & Me.TextBox12.Text
End If

Thanx

Todd Huttenstine

"Bob Phillips" wrote in message
...
Todd,

This was previously suggested to you, and it works great for me.

Private Sub TextBox1_Enter()
TextBox1.Value = "$"
End Sub

Have you tried it?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Todd Huttenstine" wrote in message
...
Hey guys,

I still cannot get a $ sign to come up before everything I type in a
textbox.


I want to be able to type in lets say TextBox1 and when I do, the $ sign
pops up in front of the number. I need the dollar sign to always be

there
no matter how many times I re-enter numbers and I need it to format the

cell
as $0.00






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
formatting a textbox Ed Excel Discussion (Misc queries) 1 February 24th 08 09:15 PM
Textbox Formatting jmc8355 Excel Discussion (Misc queries) 3 April 24th 07 06:30 PM
textbox formatting jnf40 Excel Discussion (Misc queries) 1 August 3rd 06 08:12 PM
TextBox Formatting grahammal Excel Discussion (Misc queries) 3 April 12th 06 04:54 PM
Textbox number formatting Mike[_60_] Excel Programming 1 November 14th 03 10:03 PM


All times are GMT +1. The time now is 04:02 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"