The following Macro sorts through a worksheet, copying and removing lines based on what appears in column A. If (A & i) is not a number, it triggers and moves the data to the appropriate place. The script at the moment is very slow, however. Is there an easier way to achieve this?Sub FixAbstracts()Application.ScreenUpdating = FalseDim Rng As RangeDim i As Longi = 2Dim row As RangeDim lastRow As LonglastRow = Range(A:A).Cells.SpecialCells(xlCellTypeConstants).CountWhile i <= lastRow    Set Rng = Range(A & i)    Set row = ActiveSheet.Rows(i)    lastRow = Range(A:A).Cells.SpecialCells(xlCellTypeConstants).Count    If Application.WorksheetFunction.IsNumber(Rng.Value) = True Then        i = i + 1    ElseIf IsNumeric(Rng.Value) = False And Application.WorksheetFunction.CountA(Rng) = 1 Then        Rng.Copy Destination:=Rng.Offset(-1, 13)        Rng.Delete Shift:=xlToLeft    ElseIf IsEmpty(Rng) = True And Application.CountA(row) > 0 Then        Rng.Delete Shift:=xlToLeft    ElseIf IsEmpty(Rng) = True And Application.CountA(row) = 0 Then        row.Delete    Else: Stop    End IfWendEnd Sub
Re-arranging data on a worksheet based on contents of Column A
vba;excel
Your nesting ifs have things in common, so you can restructure itOption ExplicitPublic Sub FixAbstracts()    Dim lastRow As Long    lastRow = Cells(Rows.Count, 1).End(xlUp).row    Dim i As Long    Dim rowCount As Long    Dim isEmptyCell As Boolean    For i = lastRow To 2 Step -1        isEmptyCell = IsEmpty(Cells(i, 1))        If isEmptyCell Then            rowCount = Application.CountA(Rows(i))            If rowCount > 0 Then Cells(i, 1).Delete xlshift:=xlToLeft            If rowCount = 0 Then Rows(i).Delete        ElseIf Not IsNumeric(Cells(i, 1)) Then            Cells(i - 1, 13) = Cells(i, 1)            Cells(i, 1).Delete xlshift:=xlToLeft        End If   Next iEnd SubNow you have a For loop so no need to increment i. It also steps backwards bottom to top so nothing is skipped. If you delete row(10) and go to the next row, the original row(11) is skipped. That's a result of the For loop, but it prefer it much to a Do While.Is it empty?We also declared a boolean to check for empty so it's only done once per loop. Now we base our if on that to reduce multiple checks.So now the logic isempty? Yes? Count the row. Now do somethingempty? No? is it a number by itself? Yes? Do somethingIs it a number?Let's look at the logic of yoursis it a number? yes? goto next iterationis it a number? no? is it empty? yes? Do somethingis it empty? yes? count the values in the row = 0 then do somethingis it empty? yes? count the values in the row > 0 then do somethingSee the reduction? We get rid of the initial isnumeric because the loop will iterate by itself. We also check for empty only once and we only count once.Not to mention your code is very difficult to follow.If Application.WorksheetFunction.IsNumber(Rng.Value) = True Then    i = i + 1ElseIf IsNumeric(Rng.Value) = False And Application.WorksheetFunction.CountA(Rng) = 1 Then    Rng.Copy Destination:=Rng.Offset(-1, 13)    Rng.Delete Shift:=xlToLeftElseIf IsEmpty(Rng) = True And Application.CountA(row) > 0 Then    Rng.Delete Shift:=xlToLeftElseIf IsEmpty(Rng) = True And Application.CountA(row) = 0 Then    row.DeleteElse: StopEnd IfI had to reread this a bunch of times and I'm still not sure if I'm doing all the checking you are. You aren't consistent with how you're checking for a numeric value, you use a worksheet function and the vba function, there's probably no need to use the worksheet function if your data is standardized.There's also no need to check if something like isempty = true as the result of isempty is either true or false.