arunmohanae
New Member
- Joined
- Jul 12, 2016
- Messages
- 2
Dear all,
How I can extract multiple text box values in a userform to an excel sheet through a VBA for loop. VBA script is written below. ("tb_Model" & i portion is having error)
1. Tbl_Orders is an excel table
2. tb_Model1, tb_Model2, tb_Model3, tb_Model4 and tb_Model5 are text boxes in userform
Public Sub SAVE_TO_LOG_BUTTON_Click()
Dim i As Integer
i = 1
Dim LASTROW As Long
LASTROW = ActiveWorkbook.Worksheets("Orders_and_Inventory").ListObjects("Tbl_Orders").ListRows.Count
For i = 1 To 5
If "tb_Model" & i <> "" Then
ActiveWorkbook.Worksheets("Orders_and_Inventory").ListObjects("Tbl_Orders").DataBodyRange(LASTROW + i, 6).Value = "tb_Model" & i.Value
End If
Next i
End Sub
How I can extract multiple text box values in a userform to an excel sheet through a VBA for loop. VBA script is written below. ("tb_Model" & i portion is having error)
1. Tbl_Orders is an excel table
2. tb_Model1, tb_Model2, tb_Model3, tb_Model4 and tb_Model5 are text boxes in userform
Public Sub SAVE_TO_LOG_BUTTON_Click()
Dim i As Integer
i = 1
Dim LASTROW As Long
LASTROW = ActiveWorkbook.Worksheets("Orders_and_Inventory").ListObjects("Tbl_Orders").ListRows.Count
For i = 1 To 5
If "tb_Model" & i <> "" Then
ActiveWorkbook.Worksheets("Orders_and_Inventory").ListObjects("Tbl_Orders").DataBodyRange(LASTROW + i, 6).Value = "tb_Model" & i.Value
End If
Next i
End Sub