开发者

get all unhidden rows in Excel

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜