Duplicate Delete Cell Content

danjw_98

Active Member
Joined
Oct 25, 2003
Messages
354
I am trying to delete cell data duplicates in a column. I don't want to delete the cell or row just remove the data in that cell. I have the below macro that kinda works but deletes the data from the top, leaving one at the bottom. I need to have this reversed. Any help would be appreciated....
a>
a>
a>a
b>
b>
b>b

Sub test()
finalrow = Range("a65536").End(xlUp).Row
For x = 1 To finalrow
cd1 = Range("d" & x).Value
cd2 = Range("d" & x + 1).Value
cd3 = cd2
If cd1 = cd2 Then
Range("d" & x).Value = " "
End If
Next x
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
This approach
- uses variant arrays so is much faster than ranges
- works bottom up rather than top down

hth

Dave

Code:
Sub Cull()
    Dim X()
    Dim lngRrow As Long
    X = Range([a1], Cells(Rows.Count, "A").End(xlUp)).Offset(0, 3)
    For lngrow = UBound(X, 1) To 2 Step -1
        If X(lngrow, 1) = X(lngrow - 1, 1) Then X(lngrow, 1) = vbNullString
    Next
    Range([a1], Cells(Rows.Count, "A").End(xlUp)).Offset(0, 3) = X
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,735
Members
452,939
Latest member
WCrawford

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