-1

コピーを正しく動作させることができません。「A」セルの場所をコピーの開始セルとして使用し、.end(xlup) で下から「A」セルの場所までのセルを検索し、データを含むセルのみを wbVer にコピーする必要があります (空白セルは省略)。

With wbVer.ws(1)
    for each ws in wbCs.sheets
If instr(1, ws.name, "value") then
     Set acell = ws.Cells.Find(What:=strPhone, After:=ActiveCell, LookIn:=xlValues, _
     LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
     MatchCase:=False, SearchFormat:=False)
If Not acell Is Nothing Then
     Set firstRange = wbkVer.ws("CSV").Range("A" & .Rows.Count).End(xlUp).Offset(1,                             0).Resize(acell.Rows.Count, 1)
     Set rngCSPhcell = .Range(acell.Offset(1, 0)).End(xlUp).offset(-1,0)  '<---this isn't right
     rngCSPhcell.Copy
     firstRange.PasteSpecial xlPasteValues
End if
End if

End With    
4

1 に答える 1