I have two issues that I am looking for help with.
The first, is to create a dynamic list of unique ID numbers for items matching "Horse" in column J on Sheet 2!, "Ball" in column I on Sheet 2!, and that do not contain the word dog in column A on Sheet 2! In the example below, this would return the ID numbers 48 and 56
The second, is that while I have calculated the number of assets meeting this criteria (3) , using
=COUNTIFS(Sheet2!$A:$A, " <>Dog ", Sheet2!$J:$J, "Horse", Sheet2!$I:$I, "Ball")
I would like to calculate the number of unique entries as well, which would be 2 in the example provided.
So I understand you resolved your second issue. As for the dynamic list, I believe the fastest way to do this would be using macro. If you want your unique list of ids to place in the Sheet3 it would look like this:
Sub list()
Dim pet, toy, animal As String
Dim ID, row As Integer
'pointing where list of unique ids will begin
Sheets("Sheet3").Activate
Range("A2").Select
'pointing beginig of the table with data
Sheets("Sheet2").Activate
Range("A2").Select
'loop to look for the ids
Do While IsEmpty(ActiveCell) = False
pet = ActiveCell.Value
ID = ActiveCell.Offset(0, 2).Value
toy = ActiveCell.Offset(0, 8).Value
animal = ActiveCell.Offset(0, 9).Value
If ((pet <> "dog") And (toy = "ball") And (animal = "horse")) Then
Sheets("Sheet3").Activate
ActiveCell.Value = ID
ActiveCell.Offset(1, 0).Select
Sheets("Sheet2").Activate
End If
ActiveCell.Offset(1, 0).Select
Loop
'removing duplicates from our list
Sheets("Sheet3").Activate
row = ActiveCell.row
ActiveSheet.Range("$A$2:$A$" & row).RemoveDuplicates Columns:=1, Header:=xlNo
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.