Share via

Code breaks excel

Anonymous
2023-01-24T14:47:06+00:00

When I try to run this code my excel crashes. I assume it's because it's doing something indefinitely. What is wrong with it?

Range("O5").Select

Dim m As Integer

Do While ActiveCell.Value <> ""

If InStr(ActiveCell.Value, "n") &gt; 0 Then 

    ActiveCell.Offset(0, -13).Select 

    ActiveCell.Value = m 

    If WorksheetFunction.Match(m, Range("N1:N300"), 0) = False Then 

        ActiveCell.Value.Select 

        ActiveCell.Offset(0, -1).Resize(1, 13).Select 

        Selection.Delete Shift:=xlUp 

        ActiveCell.Offset(1, 14).Resize(1, 1).Select 

    ElseIf WorksheetFunction.Match(m, Range("N1:N300"), 0) = True Then 

        ActiveCell.Value.Select 

        ActiveCell.Offset(1, 13).Select 

        ActiveCell.Offset(0, -14).Resize(1, 13).Select 

        Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove 

        ActiveCell.Offset(1, 14).Resize(1, 1).Select 

  End If 

ElseIf InStr(ActiveCell.Value, "match") &gt; 0 Then 

    ActiveCell.Offset(1, 0).Select 

End If

Loop

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments