Question

Is there a way to get an array of all the rows in VBA and then copy them to a new sheet?

I assume that the correct property is rows(index).Hidden, but I am not sure how to use this.

Is there an easy way? My problem is mainly that I can't Dim something As Rows.

Was it helpful?

Solution

To select the visible rows:

Sheets("yourSheet").Rows.SpecialCells(xlVisible).Copy
Sheets("secondSheet").Range("A1").PasteSpecial xlPasteValues

but you actually can Dim something as Rows, because the Rows property returns a Range, so you just Dim your variable as a Range.

If you want to clear your clipboard afterwards use:

Application.CutCopyMode=False

Also note that it's inefficient to use copy and paste in Excel.
You should assign one range to another if you can.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top