VBA to delete duplicate rows through out the current sheet.

ostlan

New Member
Joined
Apr 14, 2016
Messages
9
Hi,

I am trying to sort some VBA that will allow me to delete duplicate rows that could be anywhere in the current sheet.
The sheet consists of 9 columns and so the value in duplicate rows must be the same in each column for it to be counted as a duplicate.
I want to delete all duplicates but keep 1 copy of the row the search was based on.
I guess the best place to start would be to sort the sheet so it is at least a bit more uniformed.

Any help would be greatly appreciated. :)
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,301
Office Version
  1. 365
Platform
  1. Windows
If you sort the sheet you could then use the remove duplicates option on the data tab.
 

ostlan

New Member
Joined
Apr 14, 2016
Messages
9
If you sort the sheet you could then use the remove duplicates option on the data tab.
Thanks for your reply Fluff - but for this project it has to be part of a VBA scripted macro :)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,301
Office Version
  1. 365
Platform
  1. Windows
All you need to do is start the macro recorder, sort & remove duplicates then stop the recorder & you have your code. :)
 

ostlan

New Member
Joined
Apr 14, 2016
Messages
9

ADVERTISEMENT

All you need to do is start the macro recorder, sort & remove duplicates then stop the recorder & you have your code. :)
Thanks Fluff - but this seems to produce some code I can't comprehend i.e.
ActiveSheet.Range("RESP_27e9f8cd18fd44feba6060c2cd6e1e1b_[#All]").
I may need to use the macro code in another script so not sure if this would affect the operation of other scripts.

Many thanks :)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,301
Office Version
  1. 365
Platform
  1. Windows
That looks like the name of a table.
 

ostlan

New Member
Joined
Apr 14, 2016
Messages
9

ADVERTISEMENT

That looks like the name of a table.
I'm sure I can pick it apart and set the ranges manually etc.

Appreciate your help :)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,301
Office Version
  1. 365
Platform
  1. Windows
If you only have one table on the sheet you could use
VBA Code:
activesheet.ListObjects(1).DataBodyRange
 

Watch MrExcel Video

Forum statistics

Threads
1,127,107
Messages
5,622,782
Members
415,927
Latest member
vedasinternational

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
Top