Hello i could you some help with my VB code.
I am having a bit of trouble figuring out how to post values from specific cells in one sheet, say (A5, C10, D15, and E20) to a table on a second sheet on the click of a button. Values in the 2nd sheet will post to the first available row in a table until 20 rows are reached. The code i have is not working because it only posts cells from active row. This is the code i currently have:
Your help here would be greatly appreciated,
Randy
I am having a bit of trouble figuring out how to post values from specific cells in one sheet, say (A5, C10, D15, and E20) to a table on a second sheet on the click of a button. Values in the 2nd sheet will post to the first available row in a table until 20 rows are reached. The code i have is not working because it only posts cells from active row. This is the code i currently have:
Code:
Private Sub CommandButton1_Click()
Dim lst As Long
Dim CurrRw As Long
lst = Sheet5.Range("a" & Rows.Count).End(xlUp).Row + 1
CurrRw = ActiveCell.Row
If ActiveSheet.Name <> "Invoice" Then Exit Sub
If lst >= 20 Then 'alter to be the last row of table
MsgBox "Table Limit Reached!!, data will not be copied"
Exit Sub
End If
Cells(CurrRw, 1).Resize(1, 3).Copy Sheet5.Cells(lst, 1) 'copy columns A-c of ActiveRow to next available in Sheet2
End Sub
Your help here would be greatly appreciated,
Randy