Hi,
In a form with the help of a "Add" button 4 textbox will be created and when we press the add button again this will create another 4 textbox below the previous one. I am getting this correctly.
But I am not sure how I will save the values which is entered in all the text box to an excel sheet when we click on a submit button.
Also is it possible to create a new set of textbox created below automatically when a user input any value in the 4th textbox? (this will help the user not to click on the "Add" button everytime.
Below is the code which I use to generate the 4 text boxes.
Sub btnAdd_Click()
Static i As Integer
Dim txtbox, txtbox2, txtbox3, txtbox4 As Object
Set txtbox = UserForm2.Controls.Add("Forms.TextBox.1")
Set txtbox2 = UserForm2.Controls.Add("Forms.TextBox.1")
Set txtbox3 = UserForm2.Controls.Add("Forms.TextBox.1")
Set txtbox4 = UserForm2.Controls.Add("Forms.TextBox.1")
i = i + 1
With txtbox
.Name = "checkName" & i
.Left = 10
.Height = 20
.Top = 20 + (25 * i)
End With
With txtbox2
.Name = "checkName2" & i
.Left = 90
.Height = 20
.Top = 20 + (25 * i)
End With
With txtbox3
.Name = "checkName3" & i
.Left = 170
.Height = 20
.Top = 20 + (25 * i)
End With
With txtbox4
.Name = "checkName4" & i
.Left = 250
.Height = 20
.Top = 20 + (25 * i)
End With
End Sub
Can anyone please help me? Thank you in advance.