Sadsmileyface
New Member
- Joined
- Mar 21, 2013
- Messages
- 11
I'm looking to cut and paste a row from one worksheet to another within a spreadsheet if a particular cell is not blank. Then once complete, delete the original row.
If cell AM2 (and AM3,4,5 etc) on sheet 'Faults' is not blank, cut either the whole row or the range A2:AN2 (whichever is more efficient) and paste it into the next empty row on sheet 'Archive'. So each time the macro runs, it will append to the bottom of the range on 'Archive', meaning I get to keep everything and not overwrite it.
I found this online and made some changes, but I can only get it to copy and paste some of the columns rather than all, and it doesn't cut or delete:
Any advice is always appreciated.
If cell AM2 (and AM3,4,5 etc) on sheet 'Faults' is not blank, cut either the whole row or the range A2:AN2 (whichever is more efficient) and paste it into the next empty row on sheet 'Archive'. So each time the macro runs, it will append to the bottom of the range on 'Archive', meaning I get to keep everything and not overwrite it.
I found this online and made some changes, but I can only get it to copy and paste some of the columns rather than all, and it doesn't cut or delete:
Code:
Sub Archive() With Worksheets("Faults") '<--| change "OriginWs" to your actual data worksheet name
With .Range("AM2", .Cells(.Rows.Count, "AM").End(xlUp))
.AutoFilter Field:=1, Criteria1:=">0"
If Application.WorksheetFunction.Subtotal(103, .Resize(, 1)) > 1 Then .Offset(1, -8).Resize(.Rows.Count - 1, 11).SpecialCells(xlCellTypeVisible).Copy Worksheets("Sheet1").Cells(1, 1) '<--| change "TargetWs" to your actual destination worksheet name
End With
.AutoFilterMode = False
End With
End Sub
Any advice is always appreciated.