Value of a cell in a TextBox
Solved
Anonymous user
-
Anonymous user -
Anonymous user -
Hello,
In Excel, I use a UserForm that has several TextBoxes.
In order for some of these TextBoxes to display the content of certain cells, when the UserForm opens, I use the following macro:
Private Sub UserForm_Initialize()
UserForm1.TextBox1.Value = Sheets(3).Cells(3, 1).Value
UserForm1.TextBox2.Value = Sheets(3).Cells(3, 2).Value
UserForm1.TextBox3.Value = Sheets(3).Cells(3, 3).Value
UserForm1.TextBox4.Value = Sheets(3).Cells(3, 4).Value
End Sub
I would like to insert a button in my UserForm that, when clicked, will display the values of the next cells in the same sheet (those from row 4).
Do you have any idea of the code I could use in this button to do that?
Thank you in advance
Laure
In Excel, I use a UserForm that has several TextBoxes.
In order for some of these TextBoxes to display the content of certain cells, when the UserForm opens, I use the following macro:
Private Sub UserForm_Initialize()
UserForm1.TextBox1.Value = Sheets(3).Cells(3, 1).Value
UserForm1.TextBox2.Value = Sheets(3).Cells(3, 2).Value
UserForm1.TextBox3.Value = Sheets(3).Cells(3, 3).Value
UserForm1.TextBox4.Value = Sheets(3).Cells(3, 4).Value
End Sub
I would like to insert a button in my UserForm that, when clicked, will display the values of the next cells in the same sheet (those from row 4).
Do you have any idea of the code I could use in this button to do that?
Thank you in advance
Laure
3 réponses
Hello,
Try it like this:
--
Best regards,
-- Every problem has its solution. If there is no solution, where is the problem? --
Try it like this:
Dim var As Integer Private Sub CommandButton1_Click() var = var + 1 UserForm1.TextBox1.Value = Sheets(3).Cells(var, 1).Value UserForm1.TextBox2.Value = Sheets(3).Cells(var, 2).Value UserForm1.TextBox3.Value = Sheets(3).Cells(var, 3).Value UserForm1.TextBox4.Value = Sheets(3).Cells(var, 4).Value End Sub Private Sub UserForm_Initialize() var = 3 UserForm1.TextBox1.Value = Sheets(3).Cells(var, 1).Value UserForm1.TextBox2.Value = Sheets(3).Cells(var, 2).Value UserForm1.TextBox3.Value = Sheets(3).Cells(var, 3).Value UserForm1.TextBox4.Value = Sheets(3).Cells(var, 4).Value End Sub
--
Best regards,
-- Every problem has its solution. If there is no solution, where is the problem? --