當前位置:成語大全網 - 新華字典 - excel?vba編程?忽略隱藏單元格而進行公式拖動和復制

excel?vba編程?忽略隱藏單元格而進行公式拖動和復制

如果是處理自動篩選後的數據,有

示例

:

Dim

SX

As

Range,

aR

As

Range,

r

As

Range,

bt

As

Integer

'篩選區域變量

Sub

test()

Set

SX

=

ActiveSheet.AutoFilter.Range.SpecialCells(xlCellTypeVisible)

For

Each

aR

In

SX.Areas

'逐個連續區域

For

Each

r

In

aR.Rows

'逐行

If

bt

Then

'處理自動篩選出的行,用r.Cells(1,

2)引用r行的第2列

Else

'跳過標題行

bt

=

1

End

If

Next

Next

End

Sub