Forum Discussion
akennedy2225
Nov 07, 2022Copper Contributor
Split cell into multiple rows?
I have a "messy" spreadsheet I'm trying to reconfigure for analysis. There are 450 rows, but here's a sample of two: ID Name Notes 1 Test A Salaries/Benefits: $10,001.01 Purchased Service...
HansVogelaar
Nov 07, 2022MVP
You could run this macro:
Sub SplitCells()
Dim r As Long
Dim m As Long
Dim c() As String
Dim p() As String
Dim i As Long
Application.ScreenUpdating = False
m = Range("A" & Rows.Count).End(xlUp).Row
For r = m To 2 Step -1
c = Split(Range("C" & r).Value, vbLf)
If UBound(c) > 0 Then
For i = UBound(c) To 1 Step -1
Range("A" & r + 1).EntireRow.Insert
Range("A" & r + 1).Value = Range("A" & r).Value
Range("B" & r + 1).Value = Range("B" & r).Value
p = Split(c(i), ": $")
Range("C" & r + 1).Value = p(0)
Range("D" & r + 1).Value = p(1)
Next i
p = Split(c(0), ": $")
Range("C" & r).Value = p(0)
Range("D" & r).Value = p(1)
End If
Next r
Application.ScreenUpdating = True
End Sub