Skip to content

Instantly share code, notes, and snippets.

@lan2720
Last active December 2, 2018 15:07
Show Gist options
  • Save lan2720/e50bff4a249773d01ea8675cd216516d to your computer and use it in GitHub Desktop.
Save lan2720/e50bff4a249773d01ea8675cd216516d to your computer and use it in GitHub Desktop.
Sub 粘贴时跳过隐藏行()
startRow = 2
endRow = 1603
startCol = 4
endCol = 5
srcStartCol = 1
Dim Rng As Range
Dim i As Integer
For x = startCol To endCol
i = 0
Set Rng = Range(Cells(startRow, x), Cells(endRow, x)).SpecialCells(xlCellTypeVisible)
For Each cell In Rng
Worksheets("Sheet2").Cells(i + 1, srcStartCol).Copy
ActiveSheet.Paste Destination:=cell
Application.CutCopyMode = False
i = i + 1
Next
srcStartCol = srcStartCol + 1
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment