Option Explicit
Sub CutCopy()
If MsgBox("Are you sure you want to move Live or Rejected demand to Archive", vbYesNo, "+ Question") = vbYes Then
Dim DEMAND As Worksheet
Dim ARCHIVE As Worksheet
Dim lastrow As Long, i As Long, j As Long
Dim BCR As Range
Set DEMAND = Sheets("Demand Capture")
Set ARCHIVE = Sheets("Archive")
DEMAND.Unprotect
ARCHIVE.Unprotect
With DEMAND
lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
Set BCR = .Range("1:1").Find("BCR")
For i = 4 To lastrow
If .Cells(i, 1).Value = "Y" Or .Cells(i, BCR.Column).Value = "Rejected" Then
.Rows(i).Copy
j = 2
Do Until IsEmpty(ARCHIVE.Cells(j, 1))
j = j + 1
Loop
ARCHIVE.Cells(j, 1).PasteSpecial (xlPasteAll)
.Rows(i).EntireRow.Delete
i = i - 1
lastrow = lastrow - 1
End If
Next i
End With 'DEMAND
DEMAND.Protect Contents:=True, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True, DrawingObjects:=True
ARCHIVE.Protect Contents:=True, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True, DrawingObjects:=True
DEMAND.Activate
ActiveWindow.Zoom = 85
MsgBox "Archive Complete"
Else
Exit Sub
End If
End Sub
Bookmarks