I set up this code to identify a character in a column and split the contents of that column into as many rows as that character is present. It's been working for a while but now I'm receiving a run-time error. I tried to debug the code and it appears that the bolded line is the cause of the problem. Does anyone have an idea of how to fix this type of problem?
Sub splitByColB()
Dim r As Range, i As Long, ar
Set r = Worksheets("SheetNAme").Range("H999999").End(xlUp)
Do While r.Row > 1
ar = Split(r.Value, ";")
If UBound(ar) >= 0 Then r.Value = ar(0)
For i = UBound(ar) To 1 Step -1
r.EntireRow.Copy '<------------ Line causing problem
r.Offset(1).EntireRow.Insert
r.Offset(1).Value = ar(i)
Next
Set r = r.Offset(-1)
Loop
End Sub