About Text Boxes in UserForms

Dheepak

Board Regular
Joined
Aug 25, 2013
Messages
64
Hi Team,

I have created a user form with Five text boxes and also i have a command button named as "Print". Whenever i'm clicking the command button Print, only the active text box needs to print with some content like "Hello".

I was aware that in excel sheet we have to use the code ActiveCell.Value = "Hello" , the same thing i want to happen in user form for the active text box.

Can someone please help on this with code?:confused:

Regards,
Dheepak
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi Team,

I have created a user form with Five text boxes and also i have a command button named as "Print". Whenever i'm clicking the command button Print, only the active text box needs to print with some content like "Hello".

I was aware that in excel sheet we have to use the code ActiveCell.Value = "Hello" , the same thing i want to happen in user form for the active text box.

Can someone please help on this with code?:confused:
If your code is executing from within the UserForm's module, you can refer to the active control using Me.ActiveControl, for example...

MsgBox Me.ActiveControl.Name

or

MsgBox Me.ActiveControl.Value

If you are executing code in a some other module (like a subroutine in a General Module), you should be able to do this by specifying the UserForm's name in place of the Me keyword, for example...

MsgBox UserForm1.ActiveControl.Name
 
Upvote 0
Hi Rick,

Thank you so much for your quick turnaround. But when i tried this code, it reflecting a msgbox with Value as False. However, I want to fill the text box with the word "Hello" when i click the button which i created named as Print.

Below is the example form which i created:

Message 1: TextBox1
Message 2: TextBox2

(Command Button) Print Hello

So if i click Print Hello command button by placing the cursor in Textbox1, it has to print the word Hello in textbox1.

If i click Print Hello command button by placing the cursor in Textbox2, it has to print the word Hello in textbox2.

Could you place tell how to achieve this

Your Immediate Help is much appreciated!!!

Thanks & Regards,
Dheepak
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,817
Members
449,049
Latest member
cybersurfer5000

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