VBA code referring to UserForm textbox text?

PB7

Board Regular
Joined
Mar 1, 2011
Messages
58
All, I've somehow managed to fail to assimilate what maybe a simple thing:

A UserForm I have has some textbox fields, to receive text of a person's name, process status, etc.

How do you permanently save a text box value in the UserForm, and then retrieve whatever the current value of the text box is, in code like this:?

ActiveCell(Offset 0,3).Value = TextBox1.Text

Or do you also input the UserForm name as well:?

ActiveCell(Offset 0,3).Value = SampleUserFormName.TextBox1.Text

Totally stumped. Thank you in advance for any help here.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
What do you mean permanently save?

If you just mean put the value from the textbox on a worksheet either of those should work, depending on where the code is though.

The first and second one will work in the userform module.

In other modules you would need to use the second one.
 
Upvote 0
Norie, I think I get it...I need a ControlSource for a textbox, right? Which holds the text input, as entered through the UserForm. That's what I think I'm missing. Let me try this. Many thanks for the quick reply.
 
Upvote 0
Well you can use the ControlSource but you shouldn't need to.

In fact using ControlSource is sometimes not that good an idea.

It's a 2-way thing, whatever you enter in the textbox will go to the worksheet and whatever's entered on the worksheet will goto the textbox.

So if you needed to clear the userform for whatever you are doing, eg data entry, then you could end up clearing what's just been put on the worksheet.

Obviously you can get round that by moving the data on the worksheet to another location.

If you don't use ControlSource all you need is code like that you've posted to put the data from the userform onto the worksheet.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,845
Members
452,948
Latest member
UsmanAli786

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