I am getting 400 error. I was able to run the program once and it worked. However, I get the error now.
Data:
<colgroup><col width="64" style="width:48pt" span="2"> </colgroup><tbody>
</tbody>
VBA:
Sub Make2Lists()
Dim Ar As Areas
Dim Rng As Range
Dim i As Long, j As Long
Dim Ary As Variant
j = 4
Ary = Array("Planned", "Break Even")
For i = 0 To UBound(Ary)
With Range("A:A")
.Replace Ary(i), True, xlWhole, , False, , False, False
Set Ar = .SpecialCells(xlConstants, xlLogical).Areas
.Replace True, Ary(i), xlWhole, , False, , False, False
End With
For Each Rng In Ar
Rng.Resize(, 2).Copy Cells(Rows.Count, j).End(xlUp).Offset(1)
Next Rng
j = j + 3
Next i
End Sub
Data:
Original List | |
Planned | PO1 |
Break End | PO2 |
Planned | PO3 |
Break End | PO4 |
Break End | PO5 |
Planned | PO6 |
Break End | PO7 |
Planned | PO8 |
Break End | PO9 |
Planned | PO10 |
Break End | PO11 |
Planned | PO12 |
Planned | PO13 |
Planned | PO14 |
Break End | PO15 |
Planned | PO16 |
Break End | PO17 |
<colgroup><col width="64" style="width:48pt" span="2"> </colgroup><tbody>
</tbody>
VBA:
Sub Make2Lists()
Dim Ar As Areas
Dim Rng As Range
Dim i As Long, j As Long
Dim Ary As Variant
j = 4
Ary = Array("Planned", "Break Even")
For i = 0 To UBound(Ary)
With Range("A:A")
.Replace Ary(i), True, xlWhole, , False, , False, False
Set Ar = .SpecialCells(xlConstants, xlLogical).Areas
.Replace True, Ary(i), xlWhole, , False, , False, False
End With
For Each Rng In Ar
Rng.Resize(, 2).Copy Cells(Rows.Count, j).End(xlUp).Offset(1)
Next Rng
j = j + 3
Next i
End Sub