Help with basic userform

Offeror

New Member
Joined
Feb 2, 2010
Messages
4
Hi guys,

gotta fill userform textbox with a value that is in a cell in active worksheet. I've tried controlsource and it works ok but not perfect because I want the textbox to be shown empty when the form opens.

I've tried

Activesheet.Range("D43")=TextBox1.Value

thinking that it would pick the D43 value but didn't happen, but then I got rid of the activesheet coz I figured not stating it means activesheet so

Range("D43")=TextBox1.Value

But this doesn't work too.

Help needed.

Regards.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Shouldn't it be?

Code:
TextBox1.Value = Range("D43").Value

This does the opposite of what I want i.e. the user enters the text in the textbox, and that goes to range("D43").value

I want the range("D43") value to come into the textbox as soon as it is calculated (by a lookup function). But that doesn't work.

My vba is really preliminary so I might be wrong. I'm just telling from what I've experienced after giving it a shot.

Thanks.
 
Upvote 0
Your original code should work then. In what way does it not? It might be an idea to post your complete relevant code using code tags

[code]
your code here
[/code]
 
Upvote 0
Here's the code I've entered on double clicking the relevant textbox:

Rich (BB code):
Private Sub TextAdv_Change()

ActiveSheet.Range("D5").Value = TextAdv.Value

End Sub
Where Textadv is the name of the textbox. I actually also made a search from some site and I tried their suggestion too which was:

Rich (BB code):
Private Sub TextAdv_Change()

ActiveSheet.Range("D5").Value = TextAdv.Text

End Sub
Thanks for your response, and I hope I'm not doing a stupid mistake.
:-)
BTW the code I found was opposite of this, which is used to get textbox value to cell. But I tried reversing the code, hoping it might work.

Regards.
 
Last edited:
Upvote 0
That code works for me. Where did you put the code? It has to go in the userform's code module.
 
Upvote 0
You're right, I also tried it again with a fresh workbook and a very basic table so that the problem could be detected.

But when I tried it afresh, it worked perfectly. Maybe something I was doing differently before. I'm not sure. Anyways thanx a lot for your time.

I'm still working on the userform, and I'll try to figure out things best as I can, but if something doesn't work for too long I might call on you again.

Regards.
 
Upvote 0

Forum statistics

Threads
1,224,557
Messages
6,179,510
Members
452,918
Latest member
Davion615

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