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

I have a single column with numbers from which I want to eliminate duplicates.
The colums can be sorted, but one number for which duplicate(s) exist must
remain.

There are, however, no fixed amount of entries in the column.

I tried

Sub RemoveDupes()

'Add extra Column, "A" becomes "B"
Columns(1).EntireColumn.Insert

'Filter out duplicates and copy unique list to "A"
Range("B1", Range("B65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("A1"), Unique:=True

'Add extra Column, "B" becomes "A"
Columns(2).EntireColumn.Delete


but nothing happens...


--
Felix
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Eliminate Duplicates

Try this:

Sub RemoveDupes()
Range("A1").Select
Columns("A:A").AdvancedFilter Action:=xlFilterCopy,
CopyToRange:=Columns( _
"B:B"), Unique:=True
Columns("B:B").Select
Selection.Cut
Columns("A:A").Select
ActiveSheet.Paste
End Sub

Regards,
Stefi

€˛Felix€¯ ezt Ć*rta:

I have a single column with numbers from which I want to eliminate duplicates.
The colums can be sorted, but one number for which duplicate(s) exist must
remain.

There are, however, no fixed amount of entries in the column.

I tried

Sub RemoveDupes()

'Add extra Column, "A" becomes "B"
Columns(1).EntireColumn.Insert

'Filter out duplicates and copy unique list to "A"
Range("B1", Range("B65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("A1"), Unique:=True

'Add extra Column, "B" becomes "A"
Columns(2).EntireColumn.Delete


but nothing happens...


--
Felix

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Eliminate Duplicates

I tried to write this macro:

It would not accept the following line(s)

Columns("A:A").AdvancedFilter Action:=xlFilterCopy,
CopyToRange:=Columns( _
"B:B"), Unique:=True


--
Felix


"Stefi" wrote:

Try this:

Sub RemoveDupes()
Range("A1").Select
Columns("A:A").AdvancedFilter Action:=xlFilterCopy,
CopyToRange:=Columns( _
"B:B"), Unique:=True
Columns("B:B").Select
Selection.Cut
Columns("A:A").Select
ActiveSheet.Paste
End Sub

Regards,
Stefi

€˛Felix€¯ ezt Ć*rta:

I have a single column with numbers from which I want to eliminate duplicates.
The colums can be sorted, but one number for which duplicate(s) exist must
remain.

There are, however, no fixed amount of entries in the column.

I tried

Sub RemoveDupes()

'Add extra Column, "A" becomes "B"
Columns(1).EntireColumn.Insert

'Filter out duplicates and copy unique list to "A"
Range("B1", Range("B65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("A1"), Unique:=True

'Add extra Column, "B" becomes "A"
Columns(2).EntireColumn.Delete


but nothing happens...


--
Felix

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Eliminate Duplicates

Sub RemoveDupes1()

With Cells

Set rng = .Range(.Cells(1, 2), .Cells(1, 2).End(xlDown))
rng.Select
End With

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).EntireRow.Delete shift:=xlUp
End If
Next RowNdx
End Sub
--
Best wishes,

Jim


"Felix" wrote:

I have a single column with numbers from which I want to eliminate duplicates.
The colums can be sorted, but one number for which duplicate(s) exist must
remain.

There are, however, no fixed amount of entries in the column.

I tried

Sub RemoveDupes()

'Add extra Column, "A" becomes "B"
Columns(1).EntireColumn.Insert

'Filter out duplicates and copy unique list to "A"
Range("B1", Range("B65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("A1"), Unique:=True

'Add extra Column, "B" becomes "A"
Columns(2).EntireColumn.Delete


but nothing happens...


--
Felix

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Eliminate Duplicates

For Column "A"

Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))

Forgot to make the change.
--
Best wishes,

Jim


"Jim Jackson" wrote:

Sub RemoveDupes1()

With Cells

Set rng = .Range(.Cells(1, 2), .Cells(1, 2).End(xlDown))
rng.Select
End With

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).EntireRow.Delete shift:=xlUp
End If
Next RowNdx
End Sub
--
Best wishes,

Jim


"Felix" wrote:

I have a single column with numbers from which I want to eliminate duplicates.
The colums can be sorted, but one number for which duplicate(s) exist must
remain.

There are, however, no fixed amount of entries in the column.

I tried

Sub RemoveDupes()

'Add extra Column, "A" becomes "B"
Columns(1).EntireColumn.Insert

'Filter out duplicates and copy unique list to "A"
Range("B1", Range("B65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("A1"), Unique:=True

'Add extra Column, "B" becomes "A"
Columns(2).EntireColumn.Delete


but nothing happens...


--
Felix



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Eliminate Duplicates

Hello Jim,

I tried your macro as follows:

Col. A with data (numbers) (sorted)

Then I selected the cells ( A1:A313) and ran the macro with corrected line:

Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
rng.Select

I get Error message with "400" before the End If


--
Felix


"Jim Jackson" wrote:

For Column "A"

Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))

Forgot to make the change.
--
Best wishes,

Jim


"Jim Jackson" wrote:

Sub RemoveDupes1()

With Cells

Set rng = .Range(.Cells(1, 2), .Cells(1, 2).End(xlDown))
rng.Select
End With

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).EntireRow.Delete shift:=xlUp
End If
Next RowNdx
End Sub
--
Best wishes,

Jim


"Felix" wrote:

I have a single column with numbers from which I want to eliminate duplicates.
The colums can be sorted, but one number for which duplicate(s) exist must
remain.

There are, however, no fixed amount of entries in the column.

I tried

Sub RemoveDupes()

'Add extra Column, "A" becomes "B"
Columns(1).EntireColumn.Insert

'Filter out duplicates and copy unique list to "A"
Range("B1", Range("B65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("A1"), Unique:=True

'Add extra Column, "B" becomes "A"
Columns(2).EntireColumn.Delete


but nothing happens...


--
Felix

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Eliminate Duplicates

I ran it again to make sure I didn't screw anything up and it worked just
fine for me. What message did the error message have?
--
Best wishes,

Jim


"Felix" wrote:

Hello Jim,

I tried your macro as follows:

Col. A with data (numbers) (sorted)

Then I selected the cells ( A1:A313) and ran the macro with corrected line:

Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
rng.Select

I get Error message with "400" before the End If


--
Felix


"Jim Jackson" wrote:

For Column "A"

Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))

Forgot to make the change.
--
Best wishes,

Jim


"Jim Jackson" wrote:

Sub RemoveDupes1()

With Cells

Set rng = .Range(.Cells(1, 2), .Cells(1, 2).End(xlDown))
rng.Select
End With

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).EntireRow.Delete shift:=xlUp
End If
Next RowNdx
End Sub
--
Best wishes,

Jim


"Felix" wrote:

I have a single column with numbers from which I want to eliminate duplicates.
The colums can be sorted, but one number for which duplicate(s) exist must
remain.

There are, however, no fixed amount of entries in the column.

I tried

Sub RemoveDupes()

'Add extra Column, "A" becomes "B"
Columns(1).EntireColumn.Insert

'Filter out duplicates and copy unique list to "A"
Range("B1", Range("B65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("A1"), Unique:=True

'Add extra Column, "B" becomes "A"
Columns(2).EntireColumn.Delete


but nothing happens...


--
Felix

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Eliminate Duplicates

Sorry Jim,

now it works...

I must have screwed up something running it.

I had to sort first so that all duplicates are together. This is necessary,
I guess. OK?
--
Felix


"Jim Jackson" wrote:

I ran it again to make sure I didn't screw anything up and it worked just
fine for me. What message did the error message have?
--
Best wishes,

Jim


"Felix" wrote:

Hello Jim,

I tried your macro as follows:

Col. A with data (numbers) (sorted)

Then I selected the cells ( A1:A313) and ran the macro with corrected line:

Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
rng.Select

I get Error message with "400" before the End If


--
Felix


"Jim Jackson" wrote:

For Column "A"

Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))

Forgot to make the change.
--
Best wishes,

Jim


"Jim Jackson" wrote:

Sub RemoveDupes1()

With Cells

Set rng = .Range(.Cells(1, 2), .Cells(1, 2).End(xlDown))
rng.Select
End With

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).EntireRow.Delete shift:=xlUp
End If
Next RowNdx
End Sub
--
Best wishes,

Jim


"Felix" wrote:

I have a single column with numbers from which I want to eliminate duplicates.
The colums can be sorted, but one number for which duplicate(s) exist must
remain.

There are, however, no fixed amount of entries in the column.

I tried

Sub RemoveDupes()

'Add extra Column, "A" becomes "B"
Columns(1).EntireColumn.Insert

'Filter out duplicates and copy unique list to "A"
Range("B1", Range("B65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("A1"), Unique:=True

'Add extra Column, "B" becomes "A"
Columns(2).EntireColumn.Delete


but nothing happens...


--
Felix

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
eliminate duplicates on a sheet C. Brown Excel Worksheet Functions 3 April 5th 10 03:54 AM
How to eliminate everything but duplicates jtpryan Excel Worksheet Functions 2 February 17th 09 04:32 PM
Eliminate duplicates in mailing list AnneCir Excel Discussion (Misc queries) 7 April 4th 07 11:58 PM
Eliminate Duplicates in Pivot Table roadkill Excel Discussion (Misc queries) 2 February 3rd 06 06:13 PM
Ecxel Macro to summary and eliminate duplicates kdreyer Excel Programming 2 February 4th 05 10:19 PM


All times are GMT +1. The time now is 10:21 PM.

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

About Us

"It's about Microsoft Excel"