Excel中粘贴时跳过隐藏行
(2012-12-05 16:32:44)
标签:
编辑器代码专业版excel隐藏it |
分类: 奋斗 |
使用VBA,需要Microsoft
Office或者WPS专业版。
Microsoft Office下Alt+F11打开VBA编辑器。
代码如下:
Sub Func()
Dim Rng As Range
Set Rng = Range("U12:U117").SpecialCells(xlCellTypeVisible)
For Each cell In Rng
Worksheets("Sheet3").Cells(i + 1, 10).Copy
ActiveSheet.Paste Destination:=cell
Application.CutCopyMode = False
i = i + 1
If i = 39 Then End
Next
End Sub
Dim Rng As Range
Set Rng = Range("U12:U117").SpecialCells(xlCellTypeVisible)
For Each cell In Rng
Worksheets("Sheet3").Cells(i + 1, 10).Copy
ActiveSheet.Paste Destination:=cell
Application.CutCopyMode = False
i = i + 1
If i = 39 Then End
Next
End Sub
需要根据情况更改的内容:
[U12:U117] 目标数据的位置
[Sheet3] 源Sheet
[10] 源数据位于第几列 A为1 B为2 ...
[39] 数据的总行数
前一篇:oracle查询某条记录在第几行
后一篇:Python获取网页源码