Can you add data on a worksheet to a table on another sheet

skeeeter56

New Member
Joined
Nov 26, 2016
Messages
42
Office Version
  1. 2019
Platform
  1. Windows
I know how to add data to a table from a user form, can you do same thing from the values in cells on another worksheet when you click a button.

Code:
Dim lrow As Range
Dim lrow2 As Long


Set tbl = Sheets("PRP History").ListObjects("tblPRP")

    If tbl.ListRows.Count > 0 Then

        Set lrow = tbl.ListRows(tbl.ListRows.Count).Range
        For col = 1 To lrow.Columns.Count
            If Trim(CStr(lrow.Cells(1, col).Value)) <> "" Then
                tbl.ListRows.Add
                Exit For
            End If
        Next
    End If

    lrow2 = tbl.ListRows.Count

      tbl.DataBodyRange(lrow2, 1).Value = cboEmployee.Value

      tbl.DataBodyRange(lrow2, 2).Value = txtDate.Value

      tbl.DataBodyRange(lrow2, 3).Value = cboRound.Value
     
      tbl.DataBodyRange(lrow2, 4).Value = TextBox1.Value
     
      tbl.DataBodyRange(lrow2, 5).Value = TextBox2.Value
     
      tbl.DataBodyRange(lrow2, 6).Value = TextBox3.Value
     
      tbl.DataBodyRange(lrow2, 7).Value = TextBox4.Value
     
      tbl.DataBodyRange(lrow2, 8).Value = TextBox5.Value
     
      tbl.DataBodyRange(lrow2, 9).Value = TextBox6.Value
     
      tbl.DataBodyRange(lrow2, 10).Value = TextBox7.Value
     
      tbl.DataBodyRange(lrow2, 11).Value = TextBox8.Value
     
      tbl.DataBodyRange(lrow2, 12).Value = TextBox9.Value
     
      tbl.DataBodyRange(lrow2, 13).Value = TextBox10.Value
     
      tbl.DataBodyRange(lrow2, 14).Value = TextBox11.Value
     
      tbl.DataBodyRange(lrow2, 15).Value = TextBox12.Value
     

     Unload Me


End Sub



The above is the code when using a user form this all works.

But as there are calculations done based on what is inputted in, the results of which I want to save in a table and than clear the cells that have been inputed.

So is there a way I can get the values stored in certain cells to add into the fields on the table.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,224,828
Messages
6,181,201
Members
453,022
Latest member
RobertV1609

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