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.
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.