![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
I have cell J52, how can I have a textbox on a userform display that cells data?
Thanks in advance.
__________________
I appreciate the help from everyone at Mr. Excel. viper |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Assuming your textbox is named TextBox1
TextBox1.Text = Sheets(YourSheetName).Range("J52") Or TextBox1 = Range("J52") Tom |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Location: Dallas
Posts: 365
|
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?
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
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.
__________________
I appreciate the help from everyone at Mr. Excel. viper |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
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.
__________________
I appreciate the help from everyone at Mr. Excel. viper |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: May 2002
Location: Dallas
Posts: 365
|
Fantastic! Works like a charm.
Thanks. - Thomas |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
What is the value in the cell?
Tom |
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Try this...
TextBox1.Text = Format(Range("J52"), "##.##%") Tom |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Feb 2002
Location: Jefferson City, Missouri
Posts: 383
|
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?
__________________
I appreciate the help from everyone at Mr. Excel. viper |
|
|
|
|
|
#10 |
|
MrExcel MVP
Join Date: Apr 2002
Location: Vancouver BC , Canada
Posts: 6,259
|
This worked for me :
Private Sub UserForm_Initialize() TextBox1.Text = Val(Sheets("sheet 5").Range("J74")) * 100 End Sub |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|