So I'm having an issue with my current code.
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Sub ExpandRanges()
Dim X As Long, CG As Variant, Rng As Range, Cell As Range
Dim Series As String, CommaGroups() As String, DashGroups() As String
Dim j As Long, lastrow As Long
j = 0
lastrow = Cells(Rows.Count, "H").End(xlUp).Row
Set Rng = Range(Range("H2"), Range("H" & lastrow))
For Each Cell In Rng
CommaGroups = Split(Cell, ",")
For Each CG In CommaGroups
DashGroups = Split(CG, "-")
For X = DashGroups(0) To DashGroups(UBound(DashGroups))
If j = 0 Then j = Split(Cell.Address, "$")(2)
Rows(j + 1 & ":" & j + 1).Insert Shift:=xlDown
Cells(j, 9).Value = X
Range("A" & j + 1 & ":H" & j + 1).Value = Range("A" & j & ":H" & j).Value
j = j + 1
Next
Next
Next
'Band-aid solution
lastrow = Cells(Rows.Count, "H").End(xlUp).Row
Range("A" & lastrow & ":H" & lastrow).ClearContents
End Sub</code>It currently is expanding the number range for only ONE range of numbers in my excel file, any time I try to add another range it will freeze and not respond.
For example, here is my input data for just one row:
When I run my code, this is my output which is exactly what I want:
But now the issue is, whenever I got to add another row of number ranges like this:
My excel pane will freeze and tell me it is not responding.
Any ideas on how to format the code to be able to append all the expanded ranges in new rows? Thanks!!
[TABLE="width: 636"]
<tbody>[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Sub ExpandRanges()
Dim X As Long, CG As Variant, Rng As Range, Cell As Range
Dim Series As String, CommaGroups() As String, DashGroups() As String
Dim j As Long, lastrow As Long
j = 0
lastrow = Cells(Rows.Count, "H").End(xlUp).Row
Set Rng = Range(Range("H2"), Range("H" & lastrow))
For Each Cell In Rng
CommaGroups = Split(Cell, ",")
For Each CG In CommaGroups
DashGroups = Split(CG, "-")
For X = DashGroups(0) To DashGroups(UBound(DashGroups))
If j = 0 Then j = Split(Cell.Address, "$")(2)
Rows(j + 1 & ":" & j + 1).Insert Shift:=xlDown
Cells(j, 9).Value = X
Range("A" & j + 1 & ":H" & j + 1).Value = Range("A" & j & ":H" & j).Value
j = j + 1
Next
Next
Next
'Band-aid solution
lastrow = Cells(Rows.Count, "H").End(xlUp).Row
Range("A" & lastrow & ":H" & lastrow).ClearContents
End Sub</code>It currently is expanding the number range for only ONE range of numbers in my excel file, any time I try to add another range it will freeze and not respond.
For example, here is my input data for just one row:
When I run my code, this is my output which is exactly what I want:
But now the issue is, whenever I got to add another row of number ranges like this:
My excel pane will freeze and tell me it is not responding.
Any ideas on how to format the code to be able to append all the expanded ranges in new rows? Thanks!!
[TABLE="width: 636"]
<tbody>[TR]
[TD][/TD]
[/TR]
</tbody>[/TABLE]