I've heard a couple times about people needing a code to copy/paste data that never had equal amounts of rows. So why not create a defined name that traps the table for you? It would make coding more efficient, IMO.
The usual formula for a dynamic named formula would be:
=OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),1)
This works for one column. But what about a table where the amount of rows is different for each column?
I'm sure there's an easier way to do this, but here is my formula to enclose an entire table with uneven rows of data (with a KNOWN amount of columns, this case being A:C):
=OFFSET(Sheet1!$A$1,0,0,MAX(COUNTA($A:$A),COUNTA($B:$B),COUNTA($C:$C),COUNT A(Sheet1!1:1))
But when I try to define this name (by pressing "ADD"), it messes up the text with dividor signs and what looks like CHAR(10) when you don't have the cell formatted for wrapped text.
Now coming back to the "making code more efficient", here's why I think that:
-The code would be reduced TREMENDOUSLY. If there can be a defined named formula that does what I'm trying to do, here's what the code would look like:
[VBA] Option Explicit
Sub CopyPaste()
ThisWorkbook.Names.Add Name:="DynamicTable", _
RefersTo:="=OFFSET(Sheet1!$A$1,0,0,MAX(COUNTA($A:$A),COUNTA($B:$B),COUNTA($ C:$C),COUNTA(Sheet1!1:1))"
Sheets("SheetToCopy").Range("DynamicTable").Copy
Sheets("SheetToPaste").Range("A1").PasteSpecial xlAll
End Sub
[/VBA]
Now I can't test this code out....but it SHOULD work, right?
Just a thought