S
savvysam
Hey there!
So, I have an automated report that I get in Excel that reports various
production milestones, alpha, beta, ship date, etc. Each product has up to 5
versions on the report, denoted by text in one of the columns. I want to
combine all entries of a product that has consistent dates in 4 columns.
This would leave only instances of the product with unique milestones, with
the version columnconcatenating as needed. So, in essence of 7 columns I
want 6 of them to match, and if they do, they should become one with all
versions listed in column C. I've gotten help on this board, but the code
that I have now gives me runtime errors. (I've gotten the 400 error, 1004,
and another that says application or object based error.)
Any ideas for what I can do? TIA!
Here is my code:
Sub Concat()
Dim Iloop As Integer
Dim Numrows As Integer
Dim Counter As Integer
Application.ScreenUpdating = False
Numrows = Range("A65536").End(xlUp).Row
Range("A1:G" & Numrows).Select
Selection.Sort key1:=Range("A1"), Order1:=xlAscending, _
Key2:=Range("B1"), Order2:=xlAscending, Key3:=Range("C1"), _
Order3:=xlAscending, key4:=Range("D1"), Order4:=xlAscending, _
key5:=Range("E1"), Order5:=xlAscending, key6:=Range("F1"),
Order6:=xlAscending, _
key7:=Range("G1"), Order7:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
For Iloop = Numrows To 2 Step -1
If Cells(Iloop, "A") = Cells(Iloop - 1, "A") & Cells(Iloop, "B") &
Cells(Iloop - 1, "B") & Cells(Iloop, "D") = Cells(Iloop - 1, "D") _
& Cells(Iloop, "E") = Cells(Iloop - 1, "E") & Cells(Iloop, "F") =
Cells(Iloop - 1, "F") & Cells(Iloop, "G") = Cells(Iloop - 1, "G") Then
Cells(Iloop - 1, "C") = Cells(Iloop - 1, "C") & ", " & Cells(Iloop, "C")
Rows(Iloop).Delete
End If
Next Iloop
Range("A1").Select
Application.ScreenUpdating = True
End Sub
So, I have an automated report that I get in Excel that reports various
production milestones, alpha, beta, ship date, etc. Each product has up to 5
versions on the report, denoted by text in one of the columns. I want to
combine all entries of a product that has consistent dates in 4 columns.
This would leave only instances of the product with unique milestones, with
the version columnconcatenating as needed. So, in essence of 7 columns I
want 6 of them to match, and if they do, they should become one with all
versions listed in column C. I've gotten help on this board, but the code
that I have now gives me runtime errors. (I've gotten the 400 error, 1004,
and another that says application or object based error.)
Any ideas for what I can do? TIA!
Here is my code:
Sub Concat()
Dim Iloop As Integer
Dim Numrows As Integer
Dim Counter As Integer
Application.ScreenUpdating = False
Numrows = Range("A65536").End(xlUp).Row
Range("A1:G" & Numrows).Select
Selection.Sort key1:=Range("A1"), Order1:=xlAscending, _
Key2:=Range("B1"), Order2:=xlAscending, Key3:=Range("C1"), _
Order3:=xlAscending, key4:=Range("D1"), Order4:=xlAscending, _
key5:=Range("E1"), Order5:=xlAscending, key6:=Range("F1"),
Order6:=xlAscending, _
key7:=Range("G1"), Order7:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
For Iloop = Numrows To 2 Step -1
If Cells(Iloop, "A") = Cells(Iloop - 1, "A") & Cells(Iloop, "B") &
Cells(Iloop - 1, "B") & Cells(Iloop, "D") = Cells(Iloop - 1, "D") _
& Cells(Iloop, "E") = Cells(Iloop - 1, "E") & Cells(Iloop, "F") =
Cells(Iloop - 1, "F") & Cells(Iloop, "G") = Cells(Iloop - 1, "G") Then
Cells(Iloop - 1, "C") = Cells(Iloop - 1, "C") & ", " & Cells(Iloop, "C")
Rows(Iloop).Delete
End If
Next Iloop
Range("A1").Select
Application.ScreenUpdating = True
End Sub