简体   繁体   English

复制/粘贴不是entre行的数据

[英]Copy/Paste data that is not the entre row

I cannot paste anywhere besides column "A" I have tried changing the column letter, but I get an error code saying the "copy/paste cell are not the same size". 我不能粘贴除“A”列以外的任何地方我试过更改列字母,但是我得到一个错误代码,说“复制/粘贴单元格的大小不同”。

Sub HEA_Filter_Names()

Dim strArray As Variant
Dim wsSource As Worksheet
Dim wsDest As Worksheet
Dim NoRows As Long
Dim DestNoRows As Long
Dim I As Long
Dim J As Integer
Dim rngCells As Range
Dim rngFind As Range
Dim Found As Boolean

strArray = Array("ack-")

Set wsSource = ActiveSheet

NoRows = wsSource.Range("A65536").End(xlUp).Row
DestNoRows = 1
Set wsDest = Sheets("Real Alarms")

For I = 1 To NoRows

    Set rngCells = wsSource.Range("B" & I)
    Found = False

    For J = 0 To UBound(strArray)
        Found = Found Or Not (rngCells.Find(strArray(J)) Is Nothing)
    Next J

    If Found Then
        rngCells.EntireRow.Copy wsDest.Range("A" & DestNoRows)
        DestNoRows = DestNoRows + 1
    End If

Next I

End Sub

You cannot paste an EntireRow starting anywhere else than column A . 您无法从列A以外的任何位置粘贴EntireRow

You can try this instead: 您可以尝试这样做:

Intersect(rngCells.EntireRow, rngCells.Parent.UsedRange).Copy wsDest.Range("F" & DestNoRows)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM