Userform text box text disappears

dantray

New Member
Joined
Jan 7, 2014
Messages
5
Hi - new to VBA, first and foremost.

i have a userform which when opens should recall data from a range of cells in sheet 1 of my workbook.

I'm currently in testing stage so i have a command button on sheet two which will be used to initialise the userform. When I click the command button the userform appears with all fields populated. I click close and userform closes. then when I reopen this form all fields are empty.

If I do this in sheet one i can open and close as many times as I want and the information is recalled each time.

the code I am using is as follows:


Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
ComboBox1.AddItem "Straight line"
ComboBox1.AddItem "Reducing balance"
ComboBox2.AddItem "Straight line"
ComboBox2.AddItem "Reducing balance"
ComboBox3.AddItem "Straight line"
ComboBox3.AddItem "Reducing balance"
ComboBox4.AddItem "Straight line"
ComboBox4.AddItem "Reducing balance"
UserForm3.TextBox1.Value = Sheets("client data").Range("d20")
UserForm3.TextBox2.Value = Sheets("client data").Range("d22")
UserForm3.TextBox3.Value = Sheets("client data").Range("d24")
UserForm3.TextBox4.Value = Sheets("client data").Range("d27")
UserForm3.TextBox5.Value = Sheets("client data").Range("c32")
UserForm3.TextBox6.Value = Sheets("client data").Range("c33")
UserForm3.TextBox7.Value = Sheets("client data").Range("c34")
UserForm3.TextBox8.Value = Sheets("client data").Range("c35")
UserForm3.ComboBox1.Value = Sheets("client data").Range("d32")
UserForm3.ComboBox2.Value = Sheets("client data").Range("d33")
UserForm3.ComboBox3.Value = Sheets("client data").Range("d34")
UserForm3.ComboBox4.Value = Sheets("client data").Range("d35")
End Sub

any help greatly appreaciated.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,215,753
Messages
6,126,677
Members
449,327
Latest member
John4520

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