Get unique values with criteria

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,421
Office Version
  1. 2016
Platform
  1. Windows
Can anyone show me how to get a list of unique values but only if a condition is met?

So I need the unique values from Column C on Sheet10 put into Column A of Sheet18, (from A3), but only if the cell in the same row of Column A on Sheet10 has the value "Toolbox".

I can generate a unique list no problem, it's doing it with the criteria that stumps me.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
How about
Code:
Sub GetUnique()
   Dim cl As Range
   
   With CreateObject("scripting.dictionary")
      For Each cl In Sheet10.Range("C2", Sheet10.Range("C" & Rows.Count).End(xlUp))
         If cl.Offset(, -2).Value = "Toolbox" Then .Item(cl.Value) = Empty
      Next cl
      Sheet18.Range("A3").Resize(.Count).Value = Application.Transpose(.keys)
   End With
End Sub
 
Upvote 0
Fluff - thanks, works a treat.

I've just realised I need one more tweak though - that is the value from D on Sheet10 put into Column B of Sheet18.

Can you help please?
 
Upvote 0
Try
Code:
Sub GetUnique()
   Dim cl As Range
   
   With CreateObject("scripting.dictionary")
      For Each cl In Sheet10.Range("C2", Sheet10.Range("C" & Rows.Count).End(xlUp))
         If cl.Offset(, -2).Value = "Toolbox" Then .Item(cl.Value) = cl.Offset(, 1).Value
      Next cl
      Sheet18.Range("A3").Resize(.Count, 2).Value = Application.Transpose(Array(.keys, .items))
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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