How to extract multiple textbox values in userform to excel sheet through VBA using a for loop

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
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top