复制筛选单元格的列并粘贴到不同的列

Copy column of filtered cells and paste to different column

我目前正在编写一个代码来复制 CJ 列的过滤结果并将它们粘贴到 F 列中。当我尝试粘贴时,它只粘贴到未过滤的区域并删除列的其余单元格。知道正确的代码吗?

With ActiveSheet
    With Intersect(.Range("CJ:CJ"), .UsedRange)
        .Resize(.Rows.Count - 1).Offset(1).SpecialCells(xlCellTypeVisible).Copy
    End With
End With
ActiveSheet.Range("F1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, 
_Operation:=xlNone, SkipBlanks:=False, Transpose:=False

谢谢!

for i = 1 to ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
    If Range("C" & i).entireRow.hidden = False then Range("F" & i).value = Range("C" & i).value
Next i

这是我发现的满足过滤复制和粘贴的示例代码。

谢谢!

Sub CopyPasteFormula()
Dim Ws As Worksheet
Dim LRow As Long
Dim PasteRng As Range
Set Ws = Worksheets("Sheet1")
LRow = Ws.Range("K" & Rows.Count).End(xlUp).Row
Set PasteRng = Ws.Range("H1:H" & LRow).SpecialCells(xlCellTypeVisible)
Ws.Range("K:K").SpecialCells(xlCellTypeVisible).Copy
PasteRng.PasteSpecial xlPasteFormulas
Application.CutCopyMode = False 
End Sub