Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I found this from a solution Dave Peterson provided in 2006 to delete
duplicate rows based on a match in columns 1-4; how could I add code to have it sum the values in columns Q:AA and AC:AV as well? Option Explicit Sub FixDuplicateRows() Dim RowNdx As Long Dim iCol As Long Dim DeleteThisRow As Boolean Dim rng As Range For RowNdx = Selection(Selection.Cells.Count).Row To _ Selection(1).Row + 1 Step -1 DeleteThisRow = True For iCol = 1 To 4 'column A to column D If Cells(RowNdx, iCol).Value = Cells(RowNdx - 1, iCol).Value Then 'do nothing, keep looking for a difference Else DeleteThisRow = False Exit For End If Next iCol If DeleteThisRow = True Then If rng Is Nothing Then Set rng = Cells(RowNdx, 1) Else Set rng = Union(rng, Cells(RowNdx, 1)) End If End If Next RowNdx If Not rng Is Nothing Then rng.EntireRow.Delete End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I combine worksheets w/o enough rows to combine? | Excel Worksheet Functions | |||
How to merge / combine several worksheets into one new worksheet without VBA / Macro? FOR EXPERTS | Excel Worksheet Functions | |||
two worksheets, combine (merge data) | Excel Discussion (Misc queries) | |||
How do I merge or combine 2 excel worksheets by a common collumn? | Excel Worksheet Functions | |||
Combine multiple workbooks into 1 workbook w/ multiple worksheets | Excel Discussion (Misc queries) |