0
このマクロを使用して、ブック「x」からブック「y」に3列のデータをコピーし、非表示の行をコピーしません。Excel vbaマクロ:列情報を別のブックにコピー
Sub GetDataDemo()
Const FileName As String = "EHS.xlsx"
Const SheetName As String = "PO"
FilePath = "C:\Users\DD\Desktop\"
Dim wb As Workbook
Dim this As Worksheet
Dim i As Long, ii As Long
Application.ScreenUpdating = False
If IsEmpty(Dir(FilePath & FileName)) Then
MsgBox "The file " & FileName & " was not found", , "File Doesn't Exist"
Else
Set this = ActiveSheet
Set wb = Workbooks.Open(FilePath & FileName)
With wb.Worksheets(SheetName).Range("Y:AA")
ii = 3
For i = 3 To 500
If Not .Rows(i).Hidden Then
.Cells(i).Copy
this.Range("P:R").Cells(ii).Paste
ii = ii + 1
End If
Next i
End With
End If
ActiveWindow.ScreenUpdating = True
End Sub
私はラインの近くにオートメーションエラー(エラー440)を得続ける:事前にあなたの助けを
this.Range("P:R").Cells(ii).Paste
感謝を!
'.SpecialCells(xlcelltypevisible).Copy this.Range(" P3 ")'ではありませんか? – SJR
@SJR - それは同じことをしないのですか? – BruceWayne
@BruceWayne - 'Paste'は' Range'オブジェクトのメソッドではありません。 (それは 'Worksheet.Paste'または' Range.PasteSpecial'です。) – YowE3K