Deduplicate

remclave

New Member
Joined
Jul 12, 2009
Messages
2
I know this has been visited before...
Excel 2003 macro:

I routinely extract a LOT of information that requires deduplication. I get tired of walking through the same steps every time so I recorded them.


Sub DeDuplicate()
Range("A1").Select
Range("A1:C1103").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"D1"), Unique:=True
Columns("A:C").Select
Range("C1").Activate
Selection.Delete Shift:=xlToLeft
End Sub

BUT! The range isn't a fixed value. So how do I convert Range("A1:C1103") for when the last cell is not c1103?

TIA
Kat
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hello and welcome to MrExcel.

Try

Code:
Sub DeDuplicate()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("A1:C" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
"D1"), Unique:=True
Columns("A:C").Select
Range("C1").Activate
Selection.Delete Shift:=xlToLeft
End Sub
 
Upvote 0
remclave,

Try:


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


Code:
Option Explicit
Sub DeDuplicate()
Dim LR As Long
LR = Cells(Rows.Count, "C").End(xlUp).Row
Range("A1:C" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("D1"), Unique:=True

Columns("A:C").Select
Range("C1").Activate
Selection.Delete Shift:=xlToLeft
End Sub
 
Upvote 0
Suhweet!!! Thank you both for your very quick responses.

I think it's time I learn about programming in basic.... :ROFLMAO:

Thank you both again!
 
Upvote 0

Forum statistics

Threads
1,216,079
Messages
6,128,687
Members
449,464
Latest member
againofsoul

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top