olorin_117
New Member
- Joined
- Jan 19, 2022
- Messages
- 18
- Office Version
- 2019
- Platform
- Windows
Hello
I have some data in a worksheet in columns A through E...The rows of data are changing..Some day the range may be A5:E10, another day A5:E30..These data are not in a table (listobject).I am trying to paste them in a table (listobject) in another workbook.I have managed to paste them without calling the listobject method but i am trying to do so..The code I have is this
I know there is a way to add the data with the listobject.add method but I haven't figure out how
I am using Excel 2019
I have some data in a worksheet in columns A through E...The rows of data are changing..Some day the range may be A5:E10, another day A5:E30..These data are not in a table (listobject).I am trying to paste them in a table (listobject) in another workbook.I have managed to paste them without calling the listobject method but i am trying to do so..The code I have is this
VBA Code:
Private Sub copypastelines()
Dim rng As Range
montpth = ("filepath.xlsx")
Set rng = ActiveSheet.Range("A5:E" & Range("A5").End(xlDown).Row)
rng.Copy
Workbooks.Open (montpth), UpdateLinks:=False
With ActiveWorkbook
next_row = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Offset(1).Row
Sheets("Sheet1").Cells(next_row, 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
End With
ActiveWorkbook.Close True
End Sub
I know there is a way to add the data with the listobject.add method but I haven't figure out how
I am using Excel 2019