Link to home
Start Free TrialLog in
Avatar of StierInvest
StierInvest

asked on

ActiveX TextBox VBA Excel 2010

Dear Experts,

I'm having trouble to enable the user to enter a decimal number in my TextBox.
Please see code below.

Private Sub TextBox1_Change()
       
        With TextBox1
       
            .LinkedCell = "Sheet1!$P$2"
             On Error Resume Next
            ActiveWorkbook.Sheets("Sheet1").Range("P2") = CLng(Me.TextBox1)
            ActiveWorkbook.Sheets("Sheet1").Range("P2").NumberFormat = comma
             On Error GoTo 0
       End With
       
 Can someone please help.

Thanks,
K
SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of StierInvest
StierInvest

ASKER

Hi Chris,

Still no luck. As soon as I start with a "." it lets me enter it, but not "5.56" for example.

Any other ideas?

Thanks,
K
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Imnorie.

That seems to work, is there then a quick way of converting the text to a number where the cell is linked to?

Best,
K
When would you want that to happen?
Well was hoping as soon as the user enters a number. Is there not a better way by not "*1" all of the entries?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect thank you