Re: Question on a Chip Pearson macro
- From: Hash@xxxxxxxxxxx
- Date: Wed, 25 Jan 2006 19:07:08 -0500
Martin -
Thank you. Chip confirmed what we suspected.
....best, Hash
In article <CE2BD9C1-03AF-49C4-A4E4-C1A24D0E0300@xxxxxxxxxxxxx>,
Martin Fishlock <MartinFishlock@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hash:
>
> It appears that these are not needed.
>
> As always this is one of the things that VBA is lacking - code analysis,
> that is unless someone else knows otherwise.
>
> --
> HTHs Martin
>
>
> "Hash@xxxxxxxxxxx" wrote:
>
> > All -
> >
> > It is with no little temerity that I post this question about a Chip
> > Pearson macro found at:
> >
> > http://www.cpearson.com/excel/deleting.htm
> >
> > The subject is deleting duplicate rows. The code is below and I don't
> > understand variables Col, C, and N.
> >
> > Col appears assigned and never used. N appears assigned and
> > incremented, but never used. And C appears to be neither. My sense is
> > that it should be
> >
> > V = Rng.Cells(r, Col).value
> >
> > and
> >
> > ....CountIf(Col, V) > 1 Then
> >
> > But I don't know, and I don't understand, particularly N and C. N is
> > the number of deletions, but nothing seems to use N.
> >
> > Deleting Duplicate Rows is something I want to do.
> >
> > Thanks in advance, and awaiting enlightenment.
> > ....best, Hash
> >
> >
> > 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 = Active***.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
> >
.
- References:
- Question on a Chip Pearson macro
- From: Hash
- RE: Question on a Chip Pearson macro
- From: Martin Fishlock
- Question on a Chip Pearson macro
- Prev by Date: Re: Question on a Chip Pearson macro
- Next by Date: Re: Is it possible to edit multiple pivots at one time?
- Previous by thread: RE: Question on a Chip Pearson macro
- Next by thread: Re: Question on a Chip Pearson macro
- Index(es):