Sub VB_Editor()
On Error Resume Next
DeleteAllArray = Array("'", "Application.CutCopyMode = False")
DeletePartArray = Array("ActiveWindow.ScrollRow", "ActiveWindow.SmallScroll", "ActiveWindow.LargeScroll")
Application.CutCopyMode = False
LR = Sheets(1).UsedRange.Rows.Count
'Sort Empty Rows to the bottom
Range("B1:B" & LR).FormulaR1C1 = "=IF(RC[-1]="""","""",ROW())"
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("B1:B" & LR), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:B" & LR)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
For Count = 0 To UBound(DeleteAllArray)
10 ' DeleteAllArray
Range("A" & Pos & ":A" & Sheets(1).UsedRange.Rows.Count).Select
Selection.Find(What:=DeleteAllArray(Count), After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
If InStr(ActiveCell.Value, DeleteAllArray(Count)) = 0 Then GoTo 20
If Left(ActiveCell.Value, Len(strValueToPick)) = strValueToPick Then ActiveCell.EntireRow.Delete
GoTo 10
20 Next Count
LR = Sheets(1).UsedRange.Rows.Count
For Count = 0 To UBound(DeletePartArray)
Pos = 1
30 ' DeletePartArray
Range("A" & Pos & ":A" & Sheets(1).UsedRange.Rows.Count).Select
Selection.Find(What:=DeletePartArray(Count), After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
If InStr(ActiveCell.Value, DeletePartArray(Count)) = 0 Then GoTo 40
If Left(ActiveCell.Value, DeletePartArray(Count)) = DeletePartArray(Count) Then ActiveCell.EntireRow.Delete
GoTo 30
40 Next Count
'Delete ActiveCell.FormulaR1C1 = _
50 Range("A" & Pos & ":A" & Sheets(1).UsedRange.Rows.Count).Select
Selection.Find(What:="ActiveCell.FormulaR1C1 = _", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
If InStr(CStr(ActiveCell.Value), "ActiveCell.FormulaR1C1 = _") = 0 Then Pos = 1: GoTo 60
ActiveCell.Value = "ActiveCell.FormulaR1C1 = " & ActiveCell.Offset(1, 0).Value
Rows(ActiveCell.Row + 1 & ":" & ActiveCell.Row + 1).EntireRow.Delete
GoTo 50
60 ' Get rid of Select followed by select
Range("A" & Pos & ":A" & Sheets(1).UsedRange.Rows.Count).Select
Selection.Find(What:=".Select", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
If InStr(CStr(ActiveCell.Value), "Select") = 0 Then GoTo 70
Pos = ActiveCell.Row
T1 = Left(Application.Trim(Cells(Pos, 1).Value), 5)
T2 = Right(Cells(Pos, 1).Value, 6)
T3 = Left(Cells(Pos + 1, 1).Value, 5)
T4 = Right(Cells(Pos + 1, 1).Value, 6)
If Left(Application.Trim(Cells(Pos, 1).Value), 5) = "Range" And Right(Application.Trim(Cells(Pos, 1).Value), 6) = "Select" And Left(Application.Trim(Cells(Pos + 1, 1).Value), 5) = "Range" And Right(Application.Trim(Cells(Pos + 1, 1).Value), 6) = "Select" Then
Rows(Pos & ":" & Pos).EntireRow.Delete: Pos = Pos - 1
End If
Pos = Pos + 1: GoTo 60
70 ' Simplify Range Select Formula Fill.
LR = Sheets(1).UsedRange.Rows.Count
For Count = LR - 2 To 1 Step -1
If Left(Application.Trim(Cells(Count, 1).Value), 5) = "Range" And Right(Application.Trim(Cells(Count, 1).Value), 6) = "Select" And _
Left(Application.Trim(Cells(Count + 1, 1).Value), 23) = "Selection.FormulaR1C1 =" Then
Cells(Count, 1).Value = Left(Cells(Count, 1).Value, Len(Cells(Count, 1).Value) - 6) & Right(Application.Trim(Cells(Count + 1, 1).Value), Len(Application.Trim(Cells(Count + 1, 1).Value)) - 10)
Rows(Count + 1).EntireRow.Delete
End If
If Left(Application.Trim(Cells(Count, 1).Value), 5) = "Range" And Right(Application.Trim(Cells(Count, 1).Value), 6) = "Select" And _
Left(Application.Trim(Cells(Count + 1, 1).Value), 24) = "ActiveCell.FormulaR1C1 =" Then
Cells(Count, 1).Value = Left(Cells(Count, 1).Value, Len(Cells(Count, 1).Value) - 6) & Right(Application.Trim(Cells(Count + 1, 1).Value), Len(Application.Trim(Cells(Count + 1, 1).Value)) - 11)
Rows(Count + 1).EntireRow.Delete
End If
Next
End Sub
Bookmarks