This code assumes that there is always something in column A of the Rows
being moved. If that is not the case then let me know...
Public Sub MoveAllErrors()
Call MoveErrors("DRG")
Call MoveErrors("ABC")
End Sub
Private Sub MoveErrors(ByVal strToFind As String)
Dim wksCurrent As Worksheet
Dim wksNew As Worksheet
Dim rngFirst As Range
Dim rngFound As Range
Dim rngAllFound As Range
Dim rngToSearch As Range
Dim rngToPaste As Range
Const SHEETNAME As String = "Errors"
Set wksCurrent = Sheets("Sheet1")
Set rngToSearch = wksCurrent.Columns("C")
Set rngFound = rngToSearch.Find(What:=strToFind, LookAt:=xlWhole)
If Not rngFound Is Nothing Then
If SheetExists(SHEETNAME, ThisWorkbook) Then
Set wksNew = Sheets(SHEETNAME)
Else
Set wksNew = Worksheets.Add
wksNew.Name = SHEETNAME
wksCurrent.Rows(1).Copy wksNew.Range("A1")
End If
Set rngFirst = rngFound
Set rngAllFound = rngFound.EntireRow
Do
Set rngAllFound = Union(rngAllFound, rngFound.EntireRow)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = rngFirst.Address
rngAllFound.Copy
Set rngToPaste = wksNew.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
rngToPaste.PasteSpecial xlPasteValues
rngToPaste.PasteSpecial xlPasteFormats
rngAllFound.Delete
wksCurrent.Cells.Copy
Application.CutCopyMode = False
End If
End Sub
Public Function SheetExists(SName As String, _
Optional ByVal WB As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If WB Is Nothing Then Set WB = ThisWorkbook
SheetExists = CBool(Len(WB.Sheets(SName).Name))
End Function