Userform question please

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Evening,
I have a form where i have 8 text boxes & a command button just for closing the form.
I need to type in these text boxes BUT i do not wish the transfer to worksheet etc.
I need the text i type to stay in each text box.

Then later down the road i wish to edit the text in a text box & be able to then save the new text,so when i next open the form i see the newest typed text.

Please advise how i can save the text in a text box after its typed etc.

Thanks
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
The data in the userform is in memory.
If you close the userform with unload the data is lost.


If you want to keep the data, then with another button only hide the form with userform1.hide
To open the form again use a button with userform1.show
 
Upvote 0
Hi,
For some reason it doesnt show the info all the time in the textbox so i need to keep adding it in.

So i am looking to do it another way so it will always work with something like the code below.
The userform is open where the data is keep which is called GRASS

Basically when i open the userform i would like each textbox to look at its respective cell & copy that value to the text box.

So i open the userform,
TextBox1 looks at cell S3 & copies the value BANWELL
I should then be expected to see BANWELL in TextBox1

TextBox2 looks at cell T3 & copies the value HUTTON
I should then be expected to see HUTTON in TextBox2

The below when i run it shows the message.
RUN TIME ERROR 9 SUBSCRIPT OUT OF RANGE

Code:
Private Sub UserForm_Initialize()
TextBox1 = Sheets(Grass).Range("S3").Text
TextBox2 = Sheets(Grass).Range("T3").Text
TextBox3 = Sheets(Grass).Range("S4").Text
TextBox4 = Sheets(Grass).Range("T4").Text
TextBox5 = Sheets(Grass).Range("S5").Text
TextBox6 = Sheets(Grass).Range("T5").Text
TextBox7 = Sheets(Grass).Range("S6").Text
TextBox8 = Sheets(Grass).Range("T6").Text
End Sub
 
Upvote 0
Plan B now works 99%

This code is supplied below.
The only thing that doesnt work correct is if i add to the cells on the sheet the value does not show in the text box because of the Initialize code.
If i close the worksheet then open it again then the values are then show.

I obviously cant keep closing the worksheet so how can i fix this please.


Code:
Private Sub UserForm_Initialize()
TextBox1.Value = Sheets("GRASS").Range("S3")
TextBox2.Value = Sheets("GRASS").Range("s4")
TextBox3.Value = Sheets("GRASS").Range("S5")
TextBox4.Value = Sheets("GRASS").Range("s6")
TextBox5.Value = Sheets("GRASS").Range("S7")
TextBox6.Value = Sheets("GRASS").Range("T3")
TextBox7.Value = Sheets("GRASS").Range("T4")
TextBox8.Value = Sheets("GRASS").Range("T5")
TextBox9.Value = Sheets("GRASS").Range("T6")
TextBox10.Value = Sheets("GRASS").Range("T7")
End Sub
 
Upvote 0
Try, change this

Code:
Private Sub UserForm_Initialize()

By:

Code:
Private Sub UserForm_Activate()
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,743
Members
449,094
Latest member
dsharae57

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