S
Spy128Bit
The following macro works but against 30,000 rows it just isn't time
efficient. I tried to have it reset the last row each loop in an
attempt to speed it up but it had little impact. My concern is over
the array being 120 elements but I don't know much about them so that
could be the problem. Please let me know if you have any ideas or
suggestions.
Sub Auto_Combine()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
LRow = Cells(Rows.Count, "A").End(xlUp).Row
Dim ActArray As Variant
ActArray = Array("P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y",
"Z", "AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", "AI",
"AJ", "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT",
"AU", "AV", "AW", "AX", "AY", "AZ", "BA", "BB", "BC", "BD", "BE",
"BF", "BG", "BH", "BI", "BJ", "BK", "BL", "BM", "BN", "BO", "BP",
"BQ", "BR", "BS", "BT", "BU", "BV", "BW", "BX", "BY", "BZ", "CA",
"CB", "CC", "CD", "CE", "CF", "CG", "CH", "CI", "CJ", "CK", "CL",
"CM", "CN", "CO", "CP", "CQ", "CR", "CS", "CT", "CU", "CV", "CW",
"CX", "CY", "CZ", "DA", "DB", "DC", "DD", "DE", "DF", "DG", "DH",
"DI", "DJ", "DK", "DL", "DM", "DN", "DO", "DP", "DQ", "DR", "DS",
"DT", "DU", "DV", "DW", "DX", "DY", "DZ", "EA", "EB", "EC", "ED")
For Z = 2 To LRow
RowCk:
If Range("A" & Z) = Range("A" & (Z - 1)) And Range("G" & Z) =
Range("G" & (Z - 1)) Then
Rows(Z).Delete
GoTo RowCk:
End If
Reset_LastCell
LRow = Cells(Rows.Count, "A").End(xlUp).Row
For A = 0 To UBound(ActArray)
Range("" & ActArray(A) & Z & "") = Application.Evaluate("SUMPRODUCT(--
($A$2:$A$" & LRow & "=$A" & Z & "),--($G$2:$G$" & LRow & "=$G" & Z &
"),--($J$2:$J$" & LRow & "=" & ActArray(A) & "1" & "),$O$2:$O$" & LRow
& ")")
Next
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
efficient. I tried to have it reset the last row each loop in an
attempt to speed it up but it had little impact. My concern is over
the array being 120 elements but I don't know much about them so that
could be the problem. Please let me know if you have any ideas or
suggestions.
Sub Auto_Combine()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
LRow = Cells(Rows.Count, "A").End(xlUp).Row
Dim ActArray As Variant
ActArray = Array("P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y",
"Z", "AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", "AI",
"AJ", "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT",
"AU", "AV", "AW", "AX", "AY", "AZ", "BA", "BB", "BC", "BD", "BE",
"BF", "BG", "BH", "BI", "BJ", "BK", "BL", "BM", "BN", "BO", "BP",
"BQ", "BR", "BS", "BT", "BU", "BV", "BW", "BX", "BY", "BZ", "CA",
"CB", "CC", "CD", "CE", "CF", "CG", "CH", "CI", "CJ", "CK", "CL",
"CM", "CN", "CO", "CP", "CQ", "CR", "CS", "CT", "CU", "CV", "CW",
"CX", "CY", "CZ", "DA", "DB", "DC", "DD", "DE", "DF", "DG", "DH",
"DI", "DJ", "DK", "DL", "DM", "DN", "DO", "DP", "DQ", "DR", "DS",
"DT", "DU", "DV", "DW", "DX", "DY", "DZ", "EA", "EB", "EC", "ED")
For Z = 2 To LRow
RowCk:
If Range("A" & Z) = Range("A" & (Z - 1)) And Range("G" & Z) =
Range("G" & (Z - 1)) Then
Rows(Z).Delete
GoTo RowCk:
End If
Reset_LastCell
LRow = Cells(Rows.Count, "A").End(xlUp).Row
For A = 0 To UBound(ActArray)
Range("" & ActArray(A) & Z & "") = Application.Evaluate("SUMPRODUCT(--
($A$2:$A$" & LRow & "=$A" & Z & "),--($G$2:$G$" & LRow & "=$G" & Z &
"),--($J$2:$J$" & LRow & "=" & ActArray(A) & "1" & "),$O$2:$O$" & LRow
& ")")
Next
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub