Hi Julie,
Try this macro (though initially on a copy of your data as the results cannot be undone if they're not as expected) while on the sheet with the data:
Option Explicit
Sub Macro1()
Dim lngLastRow As Long
Dim lngLastCol As Long
Dim lngMyRow As Long
Dim lngMyCol As Long
Dim strMyCol As String
Application.ScreenUpdating = False
lngLastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
lngLastCol = Cells.Find("*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
With Range(Cells(2, lngLastCol + 1), Cells(lngLastRow, lngLastCol + 1))
.Formula = "=IF(AND(TRIM(D2)<>""Closed"",TRIM(D2)<>""Abandoned""),A2&B2,"""")"
.Value = .Value
End With
strMyCol = Left(Cells(1, lngLastCol + 1).Address(True, False), Application.WorksheetFunction.Search("$", Cells(1, lngLastCol + 1).Address(True, False)) - 1)
With Range(Cells(2, lngLastCol + 2), Cells(lngLastRow, lngLastCol + 2))
.Formula = "=IF(" & strMyCol & "2<>"""",COUNTIF($" & strMyCol & "$2:$" & strMyCol & "$" & lngLastRow & "," & strMyCol & "2),"""")"
.Value = .Value
End With
For lngMyRow = lngLastRow To 2 Step -1
If Val(Cells(lngMyRow, lngLastCol + 2)) > 1 Then
Rows(lngMyRow).EntireRow.Delete
End If
Next lngMyRow
For lngMyCol = lngLastCol + 2 To lngLastCol + 1 Step -1
Columns(lngMyCol).EntireColumn.Delete
Next lngMyCol
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
Regards,
Robert
Bookmarks