VBA Multiple Cell Add to Table

nlemay95

New Member
Joined
Jan 5, 2017
Messages
1
Hello!!

I have an Excel 2013 file with two worksheets, "Delivery & Quantity" and "Q Entry". The data within the "Delivery & Quantity" sheet is formatted as a table.

What I am attempting to do is take particular fields from the "Q Entry" worksheet and add them into the bottom of the table on the "Delivery & Quantity" sheet by the use of an ActiveX Control button.

Where I have hit a wall is that in my code (below) I can add the one line (row 6) but cannot add more lines from the "Q Entry" sheet.

How do I just repeat this? Or is there another action I can do that essentially does the below but adds a range of rows/columns?

Code:
Private Sub CommandButton1_Click()

Dim the_sheet As Worksheet
Dim table_list_object As ListObject
Dim table_object_row As ListRow

Set the_sheet = Sheets("Delivery & Quality")
Set table_list_object = the_sheet.ListObjects(1)
Set table_object_row = table_list_object.ListRows.Add

table_object_row.Range(1, 1).Value = Sheets("Q Entry").Range("A2")

last_row_with_data = the_sheet.Range("A65536").End(xlUp).Row
last_row_with_data = last_row_with_data

the_sheet.Range("B" & last_row_with_data) = Sheets("Q Entry").Range("B6")
the_sheet.Range("C" & last_row_with_data) = Sheets("Q Entry").Range("C6")
the_sheet.Range("D" & last_row_with_data) = Sheets("Q Entry").Range("D6")
the_sheet.Range("E" & last_row_with_data) = Sheets("Q Entry").Range("E6")
the_sheet.Range("F" & last_row_with_data) = Sheets("Q Entry").Range("F6")
the_sheet.Range("I" & last_row_with_data) = Sheets("Q Entry").Range("G6")

End Sub


Thanks for any assistance!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,215,455
Messages
6,124,938
Members
449,197
Latest member
k_bs

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