ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Evaluate duplicate rows and delete information in specified columns (https://www.excelbanter.com/excel-programming/416866-evaluate-duplicate-rows-delete-information-specified-columns.html)

S Himmelrich

Evaluate duplicate rows and delete information in specified columns
 
The following code works for only Column A:

'Removed Duplicates in Column A
Dim rng As Range
Dim i As Integer
Set rng = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
For i = rng.Rows(rng.Rows.Count).Row To rng.Row + 1 Step -1
If Cells(i, 1).Value = Cells(i - 1, 1) Then
Cells(i, 1).ClearContents
End If
Next

End Sub

I need similar results, but evaluating four columns for duplicate
rows: Columns A, C, F & G, and deleting values in Column F, G, H & I
if condition is true. Can anyone help?

joel

Evaluate duplicate rows and delete information in specified column
 
'Removed Duplicates in Column A
Dim rng As Range
Dim i As Integer
Set rng = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
For i = rng.Rows(rng.Rows.Count).Row To rng.Row + 1 Step -1
If Cells(i, "A").Value = Cells(i - 1, "A") and _
Cells(i, "C").Value = Cells(i - 1, "C") and _
Cells(i, "F").Value = Cells(i - 1, "F") and _
Cells(i, "G").Value = Cells(i - 1, "G") Then

Cells(i, "F").ClearContents
Cells(i, "G").ClearContents
Cells(i, "H").ClearContents
Cells(i, "I").ClearContents

'or this
'Range("F" & i & ":i" & i).ClearContents

End If
Next

End Sub



"S Himmelrich" wrote:

The following code works for only Column A:

'Removed Duplicates in Column A
Dim rng As Range
Dim i As Integer
Set rng = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
For i = rng.Rows(rng.Rows.Count).Row To rng.Row + 1 Step -1
If Cells(i, 1).Value = Cells(i - 1, 1) Then
Cells(i, 1).ClearContents
End If
Next

End Sub

I need similar results, but evaluating four columns for duplicate
rows: Columns A, C, F & G, and deleting values in Column F, G, H & I
if condition is true. Can anyone help?



All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com