Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Changing text to numberformat via textbox on a form

I use textboxes on a form to enter various data to some cells in a spreadsheet. (Not a table). All values are saved as text regardless of if they are actually numbers. So I tried ths:
....
With Range("MyCell")
.Value = TextBox3
.NumberFormat = "#,##0"
End With
....
The cell is now formatted as a number but I have to doubleclick it to appear as a number as it still looks like text and the green little mark says it has been saved as text!

How do I get around this?

Regards Stef

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default Changing text to numberformat via textbox on a form

Hi Stef

Formatting as number will not convert text to numbers. Why is it text in the
first place ? Shouldn't be. Anyway, you can force a number-lookalike text to
be number by multiplying it by 1:

Private Sub CommandButton1_Click()
With Range("MyCell")
.Value = TextBox3.Text
.Value = .Value * 1
.NumberFormat = "#,##0"
End With
End Sub

HTH. Best wishes Harald

"Stef" skrev i melding
...
I use textboxes on a form to enter various data to some cells in a

spreadsheet. (Not a table). All values are saved as text regardless of if
they are actually numbers. So I tried ths:
...
With Range("MyCell")
.Value = TextBox3
.NumberFormat = "#,##0"
End With
...
The cell is now formatted as a number but I have to doubleclick it to

appear as a number as it still looks like text and the green little mark
says it has been saved as text!

How do I get around this?

Regards Stef



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Changing text to numberformat via textbox on a form

Thanks! your tip fixed my problem. I do not know for sure but using textboxes to enter data from a form seems to save this data as text by default.

Stef


"Harald Staff" wrote:

Hi Stef

Formatting as number will not convert text to numbers. Why is it text in the
first place ? Shouldn't be. Anyway, you can force a number-lookalike text to
be number by multiplying it by 1:

Private Sub CommandButton1_Click()
With Range("MyCell")
.Value = TextBox3.Text
.Value = .Value * 1
.NumberFormat = "#,##0"
End With
End Sub

HTH. Best wishes Harald

"Stef" skrev i melding
...
I use textboxes on a form to enter various data to some cells in a

spreadsheet. (Not a table). All values are saved as text regardless of if
they are actually numbers. So I tried ths:
...
With Range("MyCell")
.Value = TextBox3
.NumberFormat = "#,##0"
End With
...
The cell is now formatted as a number but I have to doubleclick it to

appear as a number as it still looks like text and the green little mark
says it has been saved as text!

How do I get around this?

Regards Stef




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Changing text to numberformat via textbox on a form

Private Sub CommandButton1_Click()
With Range("MyCell")
.Value = cdbl(TextBox3.Text) ' or clng(Textbox3.Text)
.NumberFormat = "#,##0"
End With
End Sub

Everything in a textbox is text.

--
Regards,
Tom Ogilvy

"Stef" wrote in message
...
I use textboxes on a form to enter various data to some cells in a

spreadsheet. (Not a table). All values are saved as text regardless of if
they are actually numbers. So I tried ths:
...
With Range("MyCell")
.Value = TextBox3
.NumberFormat = "#,##0"
End With
...
The cell is now formatted as a number but I have to doubleclick it to

appear as a number as it still looks like text and the green little mark
says it has been saved as text!

How do I get around this?

Regards Stef



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
Text Size in Label or Textbox in Form Tony. D[_2_] Excel Discussion (Misc queries) 2 December 18th 08 02:09 PM
Form Button - Changing Text dan Excel Discussion (Misc queries) 2 February 8th 07 12:58 PM
changing a text value to a number value in a textbox? reb Excel Programming 4 April 20th 04 02:11 AM
textbox on form Glenn Robertson Excel Programming 1 March 4th 04 11:29 AM
Text to Form Textbox and back Pat[_11_] Excel Programming 5 January 19th 04 04:10 PM


All times are GMT +1. The time now is 11:40 PM.

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

About Us

"It's about Microsoft Excel"