revolvermac
New Member
- Joined
- Jun 8, 2015
- Messages
- 18
Good morning all,
I have a macro that works great for cutting/deleting specific rows, however you have to run it multiple times if there are more than one row that meets the criteria. I want to adjust it so it cuts ALL rows meeting the chosen criteria with one pass. Here's what I have so far:
Sub ClearTerminated()
'
' ClearTerminated Macro
'
'
Dim i As Variant
Dim endrow As Integer
Dim MasterList As Worksheet, Inactive As Worksheet
Set MasterList = ActiveWorkbook.Sheets("Master List")
Set Inactive = ActiveWorkbook.Sheets("Inactive")
endrow = MasterList.Range("A" & MasterList.Rows.Count).End(xlUp).Row
For i = 3 To endrow
If MasterList.Cells(i, "B").Value = "TERM" Then
MasterList.Cells(i, "B").EntireRow.Cut Destination:=Inactive.Range("A" & Inactive.Rows.Count).End(xlUp).Offset(1)
MasterList.Cells(i, "B").EntireRow.Delete
End If
Next
End Sub
I have a macro that works great for cutting/deleting specific rows, however you have to run it multiple times if there are more than one row that meets the criteria. I want to adjust it so it cuts ALL rows meeting the chosen criteria with one pass. Here's what I have so far:
Sub ClearTerminated()
'
' ClearTerminated Macro
'
'
Dim i As Variant
Dim endrow As Integer
Dim MasterList As Worksheet, Inactive As Worksheet
Set MasterList = ActiveWorkbook.Sheets("Master List")
Set Inactive = ActiveWorkbook.Sheets("Inactive")
endrow = MasterList.Range("A" & MasterList.Rows.Count).End(xlUp).Row
For i = 3 To endrow
If MasterList.Cells(i, "B").Value = "TERM" Then
MasterList.Cells(i, "B").EntireRow.Cut Destination:=Inactive.Range("A" & Inactive.Rows.Count).End(xlUp).Offset(1)
MasterList.Cells(i, "B").EntireRow.Delete
End If
Next
End Sub