How to exclude requested values?

Ofirabo

New Member
Joined
Mar 15, 2011
Messages
6
Hello,

I have many "text values" in one column, i want to exclude the values that appears just once and display them in a differnet column.
what function should i use and how?
for example:
apple
apple
apple
orange
tomato
tomato

Thanks
Ofira
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Assuming that Column A contains the text values, the following macro will list in Column C values that occur more than once...

Code:
[font=Verdana][color=darkblue]Option[/color] [color=darkblue]Explicit[/color]

[color=darkblue]Sub[/color] test()

    [color=darkblue]Dim[/color] LastRow [color=darkblue]As[/color] [color=darkblue]Long[/color]
    [color=darkblue]Dim[/color] NextRow [color=darkblue]As[/color] [color=darkblue]Long[/color]
    [color=darkblue]Dim[/color] i [color=darkblue]As[/color] [color=darkblue]Long[/color]
    
    Application.ScreenUpdating = [color=darkblue]False[/color]

    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
    NextRow = 1
    [color=darkblue]For[/color] i = 1 [color=darkblue]To[/color] LastRow
        [color=darkblue]If[/color] WorksheetFunction.CountIf(Range(Cells(1, "A"), Cells(LastRow, "A")), Cells(i, "A").Value) > 1 [color=darkblue]Then[/color]
            Cells(NextRow, "C").Value = Cells(i, "A").Value
            NextRow = [color=darkblue]Next[/color]Row + 1
        [color=darkblue]End[/color] [color=darkblue]If[/color]
    Next i
    
    Application.ScreenUpdating = [color=darkblue]True[/color]
    
    MsgBox "Completed...", vbInformation
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
[/font]

If you in fact want a list of text values than occur only once, try replacing...

Code:
If WorksheetFunction.CountIf(Range(Cells(1, "A"), Cells(LastRow, "A")), Cells(i, "A").Value) > 1 Then

with

Code:
If WorksheetFunction.CountIf(Range(Cells(1, "A"), Cells(LastRow, "A")), Cells(i, "A").Value) = 1 Then
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

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