userform question

viper

Active Member
Joined
Feb 15, 2002
Messages
382
I have cell J52, how can I have a textbox on a userform display that cells data?

Thanks in advance.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Assuming your textbox is named TextBox1

TextBox1.Text = Sheets(YourSheetName).Range("J52")

Or

TextBox1 = Range("J52")

Tom
 
Upvote 0
How about the other way? I'm new to user forms, and I've got a text box in one of them that I'd like to have the string written into it posted into a designated cell when the user form is submitted. Any thoughts?
 
Upvote 0
Assumming you want cell A1 to contain the data from your textbox.

right click on your command button on your userform, click view code.
In the command button click_event write.
Range("A1") = TextBox1.value

Thats all.
 
Upvote 0
Thank you works great. But how do I change the format of how it shows the data? Right now it shows -.229 and I need for it to show -22.9. I tried the code above and added * 100 to the end but that produced an error. I have placed ##.##% in the text value under the textbox properties but it didn't work.
 
Upvote 0
Thanks,
I tried it but it gave me a error.

The cell contains a percent (22.9). In order for my textbox to show any value I have placed my code in the userform initialize event.
Textbox1.text = sheets("sheet 5").Range("J74")

As long as I keep that code the textbox shows the value 0.229, but I need for it to show 22.9. I have placed the above code in the textbox_change event but the textbox was blank when opened. If I try and write a format code in the textbox_change event it comes up blank.

Any other ideas?
 
Upvote 0
This worked for me :

Private Sub UserForm_Initialize()
TextBox1.Text = Val(Sheets("sheet 5").Range("J74")) * 100
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,427
Messages
6,119,419
Members
448,895
Latest member
omarahmed1

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