Solved How to input a text into a textbox? (1 Viewer)

KitaYama

Well-known member
Local time
Today, 18:06
Joined
Jan 6, 2022
Messages
1,540
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:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:06
Joined
May 7, 2009
Messages
19,229
here is a demo.
see the Change event of Sheet1.
 

Attachments

  • insertText.zip
    15 KB · Views: 96

KitaYama

Well-known member
Local time
Today, 18:06
Joined
Jan 6, 2022
Messages
1,540
@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.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:06
Joined
May 7, 2009
Messages
19,229
what is MySerialNo, is it a Named Range?
if it is, you can simply use:

[MySerialNo] = 3
 

KitaYama

Well-known member
Local time
Today, 18:06
Joined
Jan 6, 2022
Messages
1,540
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

  • Book3.zip
    18.8 KB · Views: 91

Users who are viewing this thread

Top Bottom