Sub David_Macro() ' ' David_Macro Macro ' Combine Rows and Total Points ' ' Dim RowCount As Long Dim i As Long Dim j As Long 'Find out how many rows have data RowCount = ActiveSheet.Range("A:A").End(xlDown).Row For i = 2 To RowCount ' If a row value in col E is the same as the next row then... If Range("E" & i).Value = Range("E" & i + 1).Value Then ' ...start looking for all rows that follow it that have the same value For j = i + 1 To RowCount If Range("E" & j).Value = Range("E" & i).Value Then ' We've found one that's the same so add the value in column C to the first one Range("C" & i).Value = Range("C" & i).Value + Range("C" & j).Value ' Mark the row we just used for later deletion Range("K" & j).Value = "DELETE" Else Exit For End If Next i = j - 1 End If Next ' Delete the marked rows For i = RowCount To 2 Step -1 If Range("K" & i).Value = "DELETE" Then Rows(i & ":" & i).Select Selection.Delete Shift:=xlUp End If Next End Sub
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.