How to delete unique values from a column in Excel?
Usually, most of us want to remove duplicate values from a column, but sometimes, you may want to remove the unique values which appear only one time in the column. This tutorial is talking about the tricks for you to remove unique values only from a column in Excel.
Using VBA can quickly delete all unique values from one column.
1. Press Alt + F11 to display the Microsoft Visual Basic for Applications window.
2. In the window, click Insert > Module to show a new module window, then copy the following VBA code into the module window.
VBA: Delete unique values from a column.
3. Click Run button to run the VBA code, and a KutoolsforExcel dialog pops out for select a range to work. See screenshot:
Sub DeleteUnique() 'Updateby20140617 Dim Rng As Range Dim WorkRng As Range Dim Arr As Variant Dim Dic As Variant On Error Resume Next xTitleId = "KutoolsforExcel" Set WorkRng = Application.Selection Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8) Set WorkRng = WorkRng.Columns(1) Set Dic = CreateObject("Scripting.Dictionary") Arr = WorkRng.Value For i = 1 To UBound(Arr, 1) xValue = Arr(i, 1) Dic(xValue) = Dic(xValue) + 1 Next WorkRng.ClearContents Arr = WorkRng.Value xIndex = 1 For Each xKey In Dic.keys xValue = Dic(xKey) If xValue > 1 Then For i = 1 To xValue Arr(xIndex, 1) = xKey xIndex = xIndex + 1 Next End If Next WorkRng.Value = Arr End Sub
4. Click OK, and all the unique values are deleted.
If you are not familiar with VBA, you can consider to use Kutools for Excel's Select Duplicate & Unique Cells feature to remove the unique values in Excel.
1. Select the column you want to delete the unique values from, and click Kutools > Select Tools > Select Duplicate & Unique Cells. See screenshot:
2. In the pop-out dialog, check Unique values only and click Ok, and then exit this dialog. See screenshot:
3. Then all values appear only one time have been selected. And right-click to click Delete in the context menu. See screenshot:
4. In the Delete dialog, check Entire row, and click OK. See screenshot:
Now you can see the unique values are removed.
Tip: If you just want to remove the cell contents, you can click Clear Contents from the context menu in step 3.
Best Office Productivity Tools
Supports Office/Excel 2007-2021 and 365 | Available in 44 Languages | Easy to Uninstall Completely
Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need Is Just A Click Away...
Supercharge Your Excel Skills: Experience Efficiency Like Never Before with Kutools for Excel (Full-Featured 30-Day Free Trial)
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day! (Full-Featured 30-Day Free Trial)