LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Combine/Merge Rows, Multiple Worksheets

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I combine worksheets w/o enough rows to combine? Amanda W. Excel Worksheet Functions 3 June 9th 09 07:26 AM
How to merge / combine several worksheets into one new worksheet without VBA / Macro? FOR EXPERTS [email protected] Excel Worksheet Functions 9 August 13th 07 04:19 AM
two worksheets, combine (merge data) rrupp Excel Discussion (Misc queries) 2 August 1st 07 08:06 AM
How do I merge or combine 2 excel worksheets by a common collumn? Phil330 Excel Worksheet Functions 1 July 27th 06 04:22 PM
Combine multiple workbooks into 1 workbook w/ multiple worksheets buffgirl71 Excel Discussion (Misc queries) 1 May 13th 06 12:28 PM


All times are GMT +1. The time now is 02:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"