I want to remove duplicate values from rows.
I found macro that needs some adjustment.
Example table:
<tbody>
</tbody>
This macro stops after row 4, and doesn't remove B4 duplicate?
How i want it (changes bolded and colored orange) :
<tbody>
</tbody>
I found macro that needs some adjustment.
Example table:
A | B | C | D | E | F | |
1 | ||||||
2 | 275 | |||||
3 | 1348 | |||||
4 | 10 | 10 | 10 | 10 | 10 | 10 |
5 | ||||||
6 | 946 | 946 | ||||
7 | 650 | 650 | ||||
8 | 475 | |||||
9 | 477 |
<tbody>
</tbody>
Code:
Sub RemoveDuplicatesInRow()
Dim lastRow As Long
Dim lastCol As Long
Dim r As Long 'row index
Dim c As Long 'column index
Dim i As Long
With ActiveSheet.UsedRange
lastRow = .Row + .Rows.Count - 1
lastCol = .Column + .Columns.Count - 1
End With
For r = 1 To lastRow
For c = 1 To lastCol
For i = c + 1 To lastCol 'change lastCol to c+2 will remove adjacent duplicates only
If Cells(r, i) <> "" And Cells(r, i) = Cells(r, c) Then
Cells(r, i) = ""
End If
Next i
Next c
Next r
End Sub
This macro stops after row 4, and doesn't remove B4 duplicate?
How i want it (changes bolded and colored orange) :
A | B | C | D | E | |
1 | |||||
2 | 275 | ||||
3 | 1348 | ||||
4 | 10 | ||||
5 | |||||
6 | 946 | ||||
7 | 650 | ||||
8 | 475 | ||||
9 | 477 |
<tbody>
</tbody>