how to remove duplicate amount (E) and keep (D) value remain sames

kapoor2892

New Member
Joined
Jan 20, 2022
Messages
5
Office Version
  1. 2007
Platform
  1. Windows
Capture.PNG




how to remove duplicate amount (E) and keep (D) value remain sames
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Welcome to the Board!

Can you show us what your expected results should look like?
Do you want the values to then shift up, or leave blanks?
 
Upvote 0
Welcome to the Board!

Can you show us what your expected results should look like?
Do you want the values to then shift up, or leave blanks?
I want duplicate amount value to get removed. either blank or zero. example as below


Capture.PNG
 
Upvote 0
Will the duplicates always be next to each other, or could they be like this?
1642684730079.png


And could there be more than just 2, or could there also be more like this?
1642684821565.png
 
Upvote 0
OK, I think this code should do what you want:
VBA Code:
Sub RemovesDuplicates()

    Dim lr As Long
    Dim r As Long
    
    Application.ScreenUpdating = False
    
'   Find last row in column E with data
    lr = Cells(Rows.Count, "E").End(xlUp).Row
    
'   Loop through all rows backwards up to row 4
    For r = lr To 4 Step -1
'       Check to see if columns D and E match row above
        If (Cells(r, "D") = Cells(r - 1, "D")) And (Cells(r, "E") = Cells(r - 1, "E")) Then
'           Zero out value in column E
            Cells(r, "E") = 0
        End If
    Next r

    Application.ScreenUpdating = True

End Sub
 
Upvote 0
Solution
OK, I think this code should do what you want:
VBA Code:
Sub RemovesDuplicates()

    Dim lr As Long
    Dim r As Long
   
    Application.ScreenUpdating = False
   
'   Find last row in column E with data
    lr = Cells(Rows.Count, "E").End(xlUp).Row
   
'   Loop through all rows backwards up to row 4
    For r = lr To 4 Step -1
'       Check to see if columns D and E match row above
        If (Cells(r, "D") = Cells(r - 1, "D")) And (Cells(r, "E") = Cells(r - 1, "E")) Then
'           Zero out value in column E
            Cells(r, "E") = 0
        End If
    Next r

    Application.ScreenUpdating = True

End Sub
It worked. Thanks much.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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