2

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.

2
  • 1
    But where would you like to copy to, which row exactly? Commented Dec 7, 2013 at 5:33
  • 1
    To the first available (empty) row in the table. Commented Dec 7, 2013 at 5:56

1 Answer 1

3

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'.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.