Hello forum,
I have a workbook with the following code:
Sub splitByColI()
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.Calculation = xlCalculationManual
Dim r As Range, i As Long, ar
Set r = Worksheets("WorksheetName").Range("I99999").End(xlUp)
Do While r.Row > 1
ar = Split(r.Value, vbLf)
If UBound(ar) >= 0 Then r.Value = ar(0)
For i = UBound(ar) To 1 Step -1
r.EntireRow.Copy
r.Offset(1).EntireRow.Insert
r.Offset(1).Value = ar(i)
Next
Set r = r.Offset(-1)
Loop
Application.Calculation = xlCalculationAutomatic
Application.DisplayStatusBar = True
Application.ScreenUpdating = True
End Sub
In the column I have specified, I have cells with multiple lines of data that I want broken out in individual rows. The macro does the job well, my only qualm with it being that it takes a very long time even though my current data set has less than 1k rows.
Looking for any suggestions that may help improve performance.
Thank you,
Oana
I have a workbook with the following code:
Sub splitByColI()
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.Calculation = xlCalculationManual
Dim r As Range, i As Long, ar
Set r = Worksheets("WorksheetName").Range("I99999").End(xlUp)
Do While r.Row > 1
ar = Split(r.Value, vbLf)
If UBound(ar) >= 0 Then r.Value = ar(0)
For i = UBound(ar) To 1 Step -1
r.EntireRow.Copy
r.Offset(1).EntireRow.Insert
r.Offset(1).Value = ar(i)
Next
Set r = r.Offset(-1)
Loop
Application.Calculation = xlCalculationAutomatic
Application.DisplayStatusBar = True
Application.ScreenUpdating = True
End Sub
In the column I have specified, I have cells with multiple lines of data that I want broken out in individual rows. The macro does the job well, my only qualm with it being that it takes a very long time even though my current data set has less than 1k rows.
Looking for any suggestions that may help improve performance.
Thank you,
Oana