greatavion
New Member
- Joined
- Apr 3, 2023
- Messages
- 1
- Office Version
- 2010
- Platform
- Windows
Hello folks,
I have a spreadsheet that contains many rows of data. Some of the cell values in column F are duplicates while others are unique and there is only one instance. I would like to use VBA to delete the rows that contain unique values in column F, while leaving the duplicate values (+ their corresponding rows) found in column F.
I have used the below piece of code and it works fine. The problem is the data in Column B disappears on execution of the below code. As I am new to vba, unable to figure out what is the root cause.
Sub Unique_Delete()
Dim UsdRws As Long
UsdRws = Range("A" & Rows.Count).End(xlUp).Row
With Cells(1, Columns.Count).End(xlToLeft).Offset(1, 1).Resize(UsdRws)
.Formula = "=if(countifs(f:f,f2)>1,"""",1)"
.Value = .Value
.SpecialCells(xlConstants).EntireRow.Delete
End With
End Sub
Any assistance would be greatly appreciated.
I have a spreadsheet that contains many rows of data. Some of the cell values in column F are duplicates while others are unique and there is only one instance. I would like to use VBA to delete the rows that contain unique values in column F, while leaving the duplicate values (+ their corresponding rows) found in column F.
I have used the below piece of code and it works fine. The problem is the data in Column B disappears on execution of the below code. As I am new to vba, unable to figure out what is the root cause.
Sub Unique_Delete()
Dim UsdRws As Long
UsdRws = Range("A" & Rows.Count).End(xlUp).Row
With Cells(1, Columns.Count).End(xlToLeft).Offset(1, 1).Resize(UsdRws)
.Formula = "=if(countifs(f:f,f2)>1,"""",1)"
.Value = .Value
.SpecialCells(xlConstants).EntireRow.Delete
End With
End Sub
Any assistance would be greatly appreciated.