Cut Paste
Вырезанная версия
Sub CutPaste()
Const cSheet As Variant = "Sheet1" ' Worksheet Name/Index
Const cFirstS As Variant = "E" ' Source First Column Letter/Number
Const cLastS As Variant = "O" ' Source Last Column Letter/Number
Const cFirstT As Variant = "D" ' Target First Column Letter/Number
Const cFirstRow As Long = 1 ' First Row Number
Const cCriteria As Variant = "B" ' Criteria Column Letter/Number
Const cStrCriteria As String = "Plan" ' Criteria String
Dim lastRow As Long ' Last Row Number
Dim i As Long ' Row Counter
With ThisWorkbook.Worksheets(cSheet)
lastRow = .Cells(.Rows.Count, cFirstS).End(xlUp).Row
For i = cFirstRow To lastRow
If .Cells(i, cCriteria) = cStrCriteria Then
.Range(.Cells(i, cFirstS), .Cells(i, cLastS)).Cut _
Destination:=.Cells(i, cFirstT)
End If
Next
End With
End Sub
Копировать ClearContents Version
Sub CopyClearContents()
Const cSheet As Variant = "Sheet1" ' Worksheet Name/Index
Const cFirstS As Variant = "E" ' Source First Column Letter/Number
Const cLastS As Variant = "O" ' Source Last Column Letter/Number
Const cFirstT As Variant = "D" ' Target First Column Letter/Number
Const cFirstRow As Long = 1 ' First Row Number
Const cCriteria As Variant = "B" ' Criteria Column Letter/Number
Const cStrCriteria As String = "Plan" ' Criteria String
Dim lastRow As Long ' Last Row Number
Dim i As Long ' Row Counter
With ThisWorkbook.Worksheets(cSheet)
lastRow = .Cells(.Rows.Count, cFirstS).End(xlUp).Row
For i = cFirstRow To lastRow
If .Cells(i, cCriteria) = cStrCriteria Then
.Range(.Cells(i, cFirstS), .Cells(i, cLastS)).Copy _
Destination:=.Cells(i, cFirstT)
.Cells(i, cLastS).ClearContents
End If
Next
End With
End Sub