Reputation: 39
I have been unable to figure out how to paste a range (specifically one row) into a data table using VBA.
Right now there is a range of data in a worksheet named "RawData". On another sheet there is a graph that starts at (1, 1) and goes to (100, 33). The variable ThisValue contains the name of the sheet containing the table. The variable x contains the row number of the range I am attempting to transfer.
I am currently using this code:
Sheets("RawData").Select
Cells(x, 1).Resize(1, 33).Copy
Sheets(ThisValue).Select
NextRow = Cells(Rows.Count, 1).End(xlUp).row + 1
Cells(NextRow, 1).Select
ActiveSheet.Paste
The problem that I am facing is that it pastes the range of data directly below the table and not in the table. Any help would be greatly appreciated.
Upvotes: 2
Views: 37473
Reputation: 1962
Tables should be addressed as ListObjects in VBA not as Ranges/Cells.
You should find what you require here in the section 'inserting rows and columns'.
Upvotes: 3