Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Duplcate Rows for 5 Sheets
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tom Ogilvy  
View profile  
 More options Dec 20 2002, 4:45 pm
Newsgroups: microsoft.public.excel.misc
From: "Tom Ogilvy" <twogi...@msn.com>
Date: Fri, 20 Dec 2002 16:18:18 -0500
Local: Fri, Dec 20 2002 4:18 pm
Subject: Re: Duplcate Rows for 5 Sheets
untested, but I believe this will do what you want.  Change Col = 5 to refer
to the column where you want the comparison.

Public Sub DeleteDuplicateRows()
'
' This macro deletes duplicate rows based on a duplicate value in
' the column specified in the statement Col =

Dim Col As Integer
Dim r As Long
Dim C As Range
Dim V As Variant
Dim Rng As Range
Dim shArray

Col = 5   ' column E - set to your column

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

shArray = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5")

For k = UBound(shArray) To LBound(shArray)
 shArray(k).Activate

    Set Rng = ActiveSheet.UsedRange.Rows( _
      ActiveSheet.UsedRange.Rows.Count).Row

N = 0
For r = Rng.Row To 1 Step -1
    V = Cells(r, Col).Value
  For l = k To LBound(shArray)
    If l = k Then
     If Application.WorksheetFunction.CountIf(Columns(Col), V) > 1 Then
        Cells(r, Col).EntireRow.Delete
        Exit For
     End If
    Else
     If Application.CountIf(shArray(l).Columns(Col), V) > 0 Then
        Cells(r, Col).EntireRow.Delete
        Exit For
     End If
    End If
  Next l
Next r

Next k
EndMacro:

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

Regards,
Tom Ogilvy

"Str8goofE" <str8go...@aol.com> wrote in message

news:20021220142623.18019.00000340@mb-mv.aol.com...
> I copied a Macro from Chip Pearson's site that deletes duplicate rows if
there
> is a duplicate entry in a specified column(shown below)...is there anyway
to
> get this Macro to work on 5 worksheets by simply comparing the same column
in
> each of the 5 worksheets?

> Thanks!

> Public Sub DeleteDuplicateRows()
> '
> ' This macro deletes duplicate rows in the selection. Duplicates are
> ' counted in the COLUMN of the active cell.

> Dim Col As Integer
> Dim r As Long
> Dim C As Range
> Dim N As Long
> Dim V As Variant
> Dim Rng As Range

> On Error GoTo EndMacro
> Application.ScreenUpdating = False
> Application.Calculation = xlCalculationManual

> Col = ActiveCell.Column

> If Selection.Rows.Count > 1 Then
>     Set Rng = Selection
> Else
>     Set Rng = ActiveSheet.UsedRange.Rows
> End If

> N = 0
> For r = Rng.Rows.Count To 1 Step -1
>     V = Rng.Cells(r, 1).Value
>     If Application.WorksheetFunction.CountIf(Rng.Columns(1), V) > 1 Then
>         Rng.Rows(r).EntireRow.Delete
>         N = N + 1
>     End If
> Next r

> EndMacro:

> Application.ScreenUpdating = True
> Application.Calculation = xlCalculationAutomatic

> End Sub


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.