Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 148
Default comparing rows

Is there a macro that can be used to compare a row to the row above resulting
in a highlight if it is a duplicate?
What I need is to identify rows that are cell for cell duplicates - meaning
that if EVERY cell in the row is identical to the one above.

TIA
Papa

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default comparing rows

There are quite a few ways to do this. Do you know the length of each row
(number of columns)? Will it be the same number of columns every time?

Papa Jonah wrote:
Is there a macro that can be used to compare a row to the row above resulting
in a highlight if it is a duplicate?
What I need is to identify rows that are cell for cell duplicates - meaning
that if EVERY cell in the row is identical to the one above.

TIA
Papa


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200808/1

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default comparing rows

This ill do it for you, so long as every cell in the range match,
including number of used columns

Sub DupRows()
Dim MyCell As Range
Dim RowCols As Integer
Dim DupCount As Integer
Dim RowSel As Integer

RowSel = 2
Do Until RowSel = ActiveSheet.UsedRange.Rows.Count
Range("A" & RowSel & ":" & Cells(RowSel,
Columns.Count).End(xlToLeft).Address).Select
DupCount = 0
RowCols = Cells(ActiveCell.Row,
Columns.Count).End(xlToLeft).Column

For Each MyCell In Selection
If MyCell.Value = MyCell.Offset(-1, 0).Value Then
DupCount = DupCount + 1
End If
Next MyCell

If DupCount = RowCols Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End If

RowSel = RowSel + 1
Loop
End Sub

Good luck!

Steven

On Aug 7, 10:02*am, Papa Jonah
wrote:
Is there a macro that can be used to compare a row to the row above resulting
in a highlight if it is a duplicate?
What I need is to identify rows that are cell for cell duplicates - meaning
that if EVERY cell in the row is identical to the one above.

TIA
Papa


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default comparing rows

Correction (the web browser wraps this in an odd way. If you copy and
paste the code without correction line breaks, it won't work). Try
this -

Sub DupRows()
Dim MyCell As Range
Dim RowCols As Integer
Dim DupCount As Integer
Dim RowSel As Integer


RowSel = 2
Do Until RowSel = ActiveSheet.UsedRange.Rows.Count
Range("A" & RowSel & ":" & Cells(RowSel, _
Columns.Count).End(xlToLeft).Address).Select
DupCount = 0
RowCols = Cells(ActiveCell.Row,
Columns.Count).End(xlToLeft).Column


For Each MyCell In Selection
If MyCell.Value = MyCell.Offset(-1, 0).Value Then
DupCount = DupCount + 1
End If
Next MyCell


If DupCount = RowCols Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
End If


RowSel = RowSel + 1
Loop
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default comparing rows

Papa Jonah wrote:
Is there a macro that can be used to compare a row to the row above resulting
in a highlight if it is a duplicate?
What I need is to identify rows that are cell for cell duplicates - meaning
that if EVERY cell in the row is identical to the one above.

TIA
Papa

If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook

=RowsEqual(rng1,rng2) will return True or False

Alan Beban
Reply
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
comparing rows [email protected][_2_] Excel Programming 2 June 12th 06 06:04 PM
Comparing rows praveen_khm[_36_] Excel Programming 3 March 24th 06 04:19 PM
comparing rows and deletion sreedhar[_8_] Excel Programming 11 October 11th 05 02:57 AM
Comparing rows in three sheets wing Excel Programming 0 April 30th 04 05:07 PM
Comparing two rows mika.[_2_] Excel Programming 1 December 17th 03 06:27 PM


All times are GMT +1. The time now is 06:34 PM.

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

About Us

"It's about Microsoft Excel"