Solved How to input a text into a textbox?

KitaYama

Well-known member
Local time
Tomorrow, 00:57
Joined
Jan 6, 2022
Messages
2,124
I have a textbox and an activeX textbox in a sheet.
And I'm trying to input a text into them with vba.
In either case I'm receiving object doesn't support this property.

I've tested :
ActiveSheet.MySerialNo=MyVariable
MySerialNo.Value=MyVariable
ActiveSheet.MySerialNo.Value=MyVariable
ActiveSheet.MySerialNo.Text=MyVariable

What is the correct format to insert a text in a textbox?
Any kind of insight is appreciated.

Note :
  • the textboxes are on the sheet, not a userform.
  • The textbox is added from Insert tab , Textbox button
  • ActiveX textbox is added from Developer tab, Insert, ActiveX textbox

Cross posted here:
 
Last edited:
here is a demo.
see the Change event of Sheet1.
 

Attachments

@arnelgp
I need to run the code from a button on a different sheet. Or from a function in a normal module.
I still receive the same error message.

2022-07-18_06-02-50.png


Any additional insight is much appreciated.
 
what is MySerialNo, is it a Named Range?
if it is, you can simply use:

[MySerialNo] = 3
 
It's the name of the textbox.

2022-07-18_10-25-10.png


I've attached a zip. It contains a xlsm file and the only macro within this file is the following. You can be sure it doesn't harm you pc

Code:
Sub Button1_Click()
    
    Dim ws As Worksheet
    
    Set ws = Worksheets("Sheet1")
    With ws
        .MySerialNo = 32
    End With
    
End Sub
Code:
 

Attachments

Users who are viewing this thread

Back
Top Bottom