I am trying to copy a table with a dynamic range, and I would like to reference the bottom cell of the table by using the INDIRECT function. Here is my current code:
Sub CopyandPasteData()
Sheets("Pivot Tables").Select
Range(Range("H10"), Range("M10").End(xlDown)).Copy
Sheets("Final Table").Select
Range("A1").Select
Range("A1").PasteSpecial xlPasteValues
End Sub
The reason why the above formula doesn't work is because the table sometimes has blank cells in it, so using "End" will only run down to the first blank cell in the table.
So... I have a formula setup to give the bottom row of the table in a cell on the Pivot Table sheet, this formula is in Cell I8. It just returns a number, ie. "61". What I am essentially trying to do is say: Range("H10"), Range("M"&"INDIRECT"$I$8").Copy Instead of using Range("H10"), Range("M10").End(xlDown)).Copy, however this syntax is obviously not correct.
How can I go about using the INDIRECT function in this formula to find the bottom of the table?