How to input a text into a textbox?

KitaYama

New Member
Joined
May 18, 2022
Messages
10
Office Version
  1. 365
Platform
  1. Windows
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
  • The code is going to be executed from a button on a different sheet or from a public sub in a module

Thanks again.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
It's my first post here and I'm not familiar with rules here.
I have the same question here on other forums with no solution yet.
Should I add the address of a cross post or not?

thanks.
 
Upvote 0
Yes, you should do that on all forums you post your question to. That way, the volunteers can check if you have a solution yet before they spend time trying to develop one for you.

As to your question, if the button where the code will be attached is on a different worksheet, then you need to have the textboxes reference the sheet they are on, not the ActiveSheet (the active sheet will be the one where the button is being clicked).
 
Upvote 0
Cross posted here:

@Rick Rothstein
I'll test and will be back. Thanks for your quick support.
 
Upvote 0
then you need to have the textboxes reference the sheet they are on
I'm exactly doing the same thing.
The textbox is on Sheet1.
The button is on Sheet2.

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

I'm receiving method or data member not found erro.

Thanks for your time.
 
Upvote 0
You haven't shown all your code, so I cannot be sure of this, but remove the .Activate statement (you do not have to activate a sheet to do things on it, especially when you have a direct reference to it) and see if the code works then.
 
Upvote 0
You haven't shown all your code, so I cannot be sure of this, but remove the .Activate statement (you do not have to activate a sheet to do things on it, especially when you have a direct reference to it) and see if the code works then.
I don't have any other code. It's an empty file just for testing. What you see above is the only code in the workbook.
I can't compile the file. I receive the mentioned error .MySerialNo=32.

Just for the sake of testing, I followed your instruction an removed the .Activate line.
Still the same error on the same line.

Thanks for your time.
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,039
Members
449,063
Latest member
ak94

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top