PDA

View Full Version : label caption



av8tordude
08-27-2012, 02:49 PM
I'm trying to enter a number display in a label into a textbox. For some reason, its entering it as a text. The code I'm using is below. I need to enter the number display in the label into textbox (as a number), so I can enter it into the worksheet. Can someone assist. Thanks

Textbox1.Value = Label16.Caption

snb
08-27-2012, 03:32 PM
[A1]=label16.caption

av8tordude
08-27-2012, 03:38 PM
forgive me...but what is [A1]?
Sorry I should have mention, this label and textboxes are on a userform

av8tordude
08-27-2012, 04:17 PM
ok...I think I discovered the source of the error. this code..

Cells(ActiveCell.Row, 95)
is storing the number in the textbox as a text. Its also storing the number into the sheet as a text. So I guess my question, now, is how do I store the value as a number and not a text?

Kenneth Hobs
08-27-2012, 06:21 PM
[A1]=Range("A1")=Cells(1, 1)

A caption and a textbox are strings. What is the value of your label caption?

Range("A1").Value = Label16.Caption

You can use CInt(), CDbl(), CLng(), if you like.

snb
08-28-2012, 01:49 AM
You'll have to format cells(j,95) to 'general' (in any case not 'text/string')
Excel interprets every number automatically as number if you write it into a worksheet, no matter whether is has been presented as a string or not.