如何设置一个范围等于两列中不相邻的可见单元格

How to set a range equal to visible cells in two columns which are not next to each other

我过滤了 A 到 J 列,因此隐藏了一些行。第 1 行始终是 header 行,我不希望这样。 我只想要 E 和 J 列中可见单元格的范围 object。请注意,可见行之间会有隐藏行。

谢谢 安德鲁。

试试下面的方法。我做了一些明显的假设,你必须修改。

With worksheets("mySheet")

     Dim lastRow as Long
     lastRow = .Cells(.Rows.Count,1).end(xlup).Row

     Dim filterRange as Range
     Set filterRange = .Range("A1:J" & lastRow)

     With filterRange

         .AutoFilter 1, "myFilter"

         Set region1Range as Range
         Set region1Range = .Columns(5).SpecialCells(xlCellTypeVisible)

         Set region2Range as Range
         Set region2Range = .Columns(10).SpecialCells(xlCellTypeVisible)

    End With

End With

Dim regionRange
Set regionRange = Union(region1Range, region2Range)