Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Find duplication Macro

Hi Folks I use this to find me dups, I just highlight the Column and go:

Sub FixDuplicateRows()
Dim RowNdx As Long
Dim ColNum As Integer
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
If Cells(RowNdx, ColNum).Value = Cells(RowNdx - 1, ColNum).Value Then
Cells(RowNdx, ColNum).Value = ""
End If
Next RowNdx
End Sub

However, if I have a number in row 2 and row 10 it doesn't get ride of the
number. With the marco I'm using the number has to be directly below it..
Anyone got a fix?
Thanks
DJ
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find duplication Macro

Sub FixDuplicateRows()
Dim RowNdx As Long
Dim ColNum As Integer
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
set rng = Range(selection(1),Cells(rowNdx-1,ColNum))
If Application.countif(rng,Cells(RowNdx, ColNum).Value) = 1 Then
Cells(RowNdx, ColNum).ClearContents
End If
Next RowNdx
End Sub

--
Regards,
Tom Ogilvy


"Duncan_J" wrote in message
...
Hi Folks I use this to find me dups, I just highlight the Column and go:

Sub FixDuplicateRows()
Dim RowNdx As Long
Dim ColNum As Integer
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
If Cells(RowNdx, ColNum).Value = Cells(RowNdx - 1, ColNum).Value Then
Cells(RowNdx, ColNum).Value = ""
End If
Next RowNdx
End Sub

However, if I have a number in row 2 and row 10 it doesn't get ride of the
number. With the marco I'm using the number has to be directly below it..
Anyone got a fix?
Thanks
DJ



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find duplication Macro

forgot to declare rng:

Sub FixDuplicateRows()
Dim RowNdx As Long
Dim ColNum As Integer
Dim rng As Range
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
Set rng = Range(Selection(1), Cells(RowNdx - 1, ColNum))
If Application.CountIf(rng, Cells(RowNdx, ColNum).Value) = 1 Then
Cells(RowNdx, ColNum).ClearContents
End If
Next RowNdx
End Sub

--
Regards,
Tom Ogilvy

"Duncan_J" wrote in message
...
Hi Folks I use this to find me dups, I just highlight the Column and go:

Sub FixDuplicateRows()
Dim RowNdx As Long
Dim ColNum As Integer
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
If Cells(RowNdx, ColNum).Value = Cells(RowNdx - 1, ColNum).Value Then
Cells(RowNdx, ColNum).Value = ""
End If
Next RowNdx
End Sub

However, if I have a number in row 2 and row 10 it doesn't get ride of the
number. With the marco I'm using the number has to be directly below it..
Anyone got a fix?
Thanks
DJ



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Find duplication Macro

Thanks Tom

"Tom Ogilvy" wrote:

forgot to declare rng:

Sub FixDuplicateRows()
Dim RowNdx As Long
Dim ColNum As Integer
Dim rng As Range
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
Set rng = Range(Selection(1), Cells(RowNdx - 1, ColNum))
If Application.CountIf(rng, Cells(RowNdx, ColNum).Value) = 1 Then
Cells(RowNdx, ColNum).ClearContents
End If
Next RowNdx
End Sub

--
Regards,
Tom Ogilvy

"Duncan_J" wrote in message
...
Hi Folks I use this to find me dups, I just highlight the Column and go:

Sub FixDuplicateRows()
Dim RowNdx As Long
Dim ColNum As Integer
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
If Cells(RowNdx, ColNum).Value = Cells(RowNdx - 1, ColNum).Value Then
Cells(RowNdx, ColNum).Value = ""
End If
Next RowNdx
End Sub

However, if I have a number in row 2 and row 10 it doesn't get ride of the
number. With the marco I'm using the number has to be directly below it..
Anyone got a fix?
Thanks
DJ




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
Duplication Macro stew Excel Discussion (Misc queries) 0 February 19th 09 12:28 PM
Duplication Welthey Excel Discussion (Misc queries) 2 January 15th 07 09:48 PM
Range Name Duplication and PasteSpecial Macro Mike Wrob Excel Programming 3 January 10th 05 04:32 PM
I need to find a macro to find data cut and paste to another colu. Rex Excel Programming 6 December 7th 04 09:22 AM
Excel macro - Help with duplication validation macro princess[_2_] Excel Programming 3 January 8th 04 06:39 PM


All times are GMT +1. The time now is 10:37 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"