Delete repeated Values in excel

rival36

New Member
Joined
May 31, 2019
Messages
41
Office Version
  1. 2016
Platform
  1. Windows
I want to delete repeated values in excel sheet. I mean if the previous cell contains the same value as in current cell, return current cell value as zero. please go through the screenshot.
Please help
 

Attachments

  • Untitled.png
    Untitled.png
    19.5 KB · Views: 10

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
VBA Code:
Sub Maybe_A()
Dim i As Long
    For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
        If Cells(i, 1).Value = Cells(i, 1).Offset(-1).Value Then Cells(i, 1).Value = 0
    Next i
End Sub
VBA Code:
Sub Maybe_B()
Dim i As Long
    For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
        If Cells(i, 1).Value = Cells(i - 1, 1).Value Then Cells(i, 1).Value = 0
    Next i
End Sub
 
Upvote 0
Put this FORMULA in E5 if you want to use helper column to get what you want
=IF(A5=A4,0,A5)
 
Last edited:
Upvote 0
Another option
VBA Code:
Sub rival36()
   With Range("A5", Range("A" & Rows.Count).End(xlUp))
      .Value = Evaluate("if(" & .Address & "=" & .Offset(-1).Address & ",0, " & .Address & ")")
   End With
End Sub
 
Upvote 0
VBA Code:
Sub Maybe_A()
Dim i As Long
    For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
        If Cells(i, 1).Value = Cells(i, 1).Offset(-1).Value Then Cells(i, 1).Value = 0
    Next i
End Sub
VBA Code:
Sub Maybe_B()
Dim i As Long
    For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
        If Cells(i, 1).Value = Cells(i - 1, 1).Value Then Cells(i, 1).Value = 0
    Next i
End Sub
Not working sir, I want to use excel formula and not VB,
m using some logic and i want that if previous cell having same value as current cell it
Untitled.png
should return zero in current cell
 
Upvote 0
If you don't want to use a second column, then you will have to use VBA. A cell can contain a hard value or a formula, but not both.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,198
Members
453,022
Latest member
RobertV1609

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