[英]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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.