Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Question on a Chip Pearson macro

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 = 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Question on a Chip Pearson macro

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


" 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 = 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Question on a Chip Pearson macro

Those variables are left-overs from a more complicated macro from
which this one was adapted. They are not needed.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
news:0BABf.11990$bF.8146@dukeread07...
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 = 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Question on a Chip Pearson macro

Chip -

Thank you, and thank you for showing the way. I was about to start a
sorting macro that put duplicates together and de-dupe from there.

No surprise, but your way is better.

....best, Hash

In article ,
"Chip Pearson" wrote:

Those variables are left-overs from a more complicated macro from
which this one was adapted. They are not needed.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


wrote in message
news:0BABf.11990$bF.8146@dukeread07...
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 = 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Question on a Chip Pearson macro

Martin -

Thank you. Chip confirmed what we suspected.

....best, Hash
In article ,
Martin Fishlock 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


" 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 = 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

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
Question to Chip Pearson Doug[_9_] Excel Programming 2 January 19th 04 03:56 PM
Chip Pearson: A Question about RegServ32 and DLLs :) Mike-hime Excel Programming 2 January 6th 04 06:26 PM
Chip Pearson Ricardo[_2_] Excel Programming 0 November 10th 03 07:51 PM
CHIP PEARSON - THANX bertieBassett Excel Programming 0 November 3rd 03 02:01 PM
Chip Pearson or someone Chip Pearson Excel Programming 3 September 18th 03 05:22 AM


All times are GMT +1. The time now is 09:12 AM.

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"