Hello,
I'm messing around with Userforms and have been trying to get all the values of textboxes within' my Userform to save and match up with what's in the worksheet its supposed to be editing.
I took a very basic approach to this and have the start of my code looking like this :
The issue I'm having is that only the first line of code is being registered when the CommandButton1 is being clicked. So the value of TextBox1 will change properly, but TextBox2 and anything added beyond this code gets ignored.
The Initialization for the Userform copies the text on the worksheet into the text boxes just fine.
Just as an example :
I have a much larger quantity of fields I want entered in this Userform but can't seem to get over this fundamental problem.. Could anyone possibly guide me in the right direction of how I should have the code set-up instead so it doesn't do this?
Thank you!
I'm messing around with Userforms and have been trying to get all the values of textboxes within' my Userform to save and match up with what's in the worksheet its supposed to be editing.
I took a very basic approach to this and have the start of my code looking like this :
VBA Code:
Private Sub CommandButton1_Click()
Sheets("Sheet1").Range("B4") = TextBox1.Value
Sheets("Sheet1").Range("B5") = TextBox2.Value
End Sub
Private Sub UserForm_Initialize()
TextBox1.Value = Sheets("Sheet1").Range("B4")
TextBox2.Value = Sheets("Sheet1").Range("B5")
End Sub
The issue I'm having is that only the first line of code is being registered when the CommandButton1 is being clicked. So the value of TextBox1 will change properly, but TextBox2 and anything added beyond this code gets ignored.
The Initialization for the Userform copies the text on the worksheet into the text boxes just fine.
Just as an example :
B4 = "ABC"
B5 = "123"
Opening the Userform has TextBox1 = "ABC" and TextBox2 = "123"
Changing TextBox1 to equal "DEF" and TextBox2 to equal "456" and pressing the CommandButton1 in order to apply these changes to the Worksheet
Only TextBox1's change to "DEF" saved, but it skipped over the TextBox2's change to "456."
No errors occur at any point.
B5 = "123"
Opening the Userform has TextBox1 = "ABC" and TextBox2 = "123"
Changing TextBox1 to equal "DEF" and TextBox2 to equal "456" and pressing the CommandButton1 in order to apply these changes to the Worksheet
Only TextBox1's change to "DEF" saved, but it skipped over the TextBox2's change to "456."
No errors occur at any point.
I have a much larger quantity of fields I want entered in this Userform but can't seem to get over this fundamental problem.. Could anyone possibly guide me in the right direction of how I should have the code set-up instead so it doesn't do this?
Thank you!