View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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