Add new row and add data of one cell to a specific cell through Button

sidvix

New Member
Joined
Jan 6, 2020
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to add a new row with specific formulas/dropdown lists. I need to be able to add new row and copy customer name from one cell to specific cell in last row.


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("PotentialOrders")
Set table_list_object = the_sheet.ListObjects(1)
Set table_object_row = table_list_object.ListRows.add

table_object_row.Range(1, 1).Value = "0"
table_object_row.Range(1, 3).Value = 'Pick up data from cell "C1" everytime and paste it in Column C (last row)'
table_object_row.Range(1, 6).Value = "Enter Potential Shipping Date"
table_object_row.Range(1, 8).Value = "Select Item No."
table_object_row.Range(1, 9).Value = "Select Packing Type"
table_object_row.Range(1, 10).Value = "Enter Quantity"
table_object_row.Range(1, 11).Value = "Enter Unit Price"

With the_sheet.Cells(the_sheet.Rows.Count, "A").End(xlUp)
.Select ' not required to change the focus/view
ActiveWindow.ScrollRow = .Row
End With

End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Change this:
table_object_row.Range(1, 3).Value = 'Pick up data from cell "C1" everytime and paste it in Column C (last row)'

For this:
VBA Code:
table_object_row.Range(1, 3).Value = the_sheet.Range("C1").Value
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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