List Values On New Sheet If Criteria Is Met

Nanogirl21

Active Member
Joined
Nov 19, 2013
Messages
331
Office Version
  1. 365
Platform
  1. Windows
I have data set up in the format below.


You will see that there are duplicate values in column B and some duplicate values in column C.


Is there a way to list the parent value (column B) when all child values (column C) related to that parent says “Chris”?


I’d like the list to be on a new sheet called COMPLETE. This sheet is not created yet and would need to be created each time. The main sheet that the information is in is called MATH.


CURRENT FORMAT

[TABLE="width: 500, align: left"]
<tbody>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[/TR]
[TR]
[TD]1232
[/TD]
[TD]APPLES
[/TD]
[TD]CHRIS
[/TD]
[/TR]
[TR]
[TD]1233
[/TD]
[TD]APPLES
[/TD]
[TD]CHRIS
[/TD]
[/TR]
[TR]
[TD]1234
[/TD]
[TD]APPLES
[/TD]
[TD]CHRIS
[/TD]
[/TR]
[TR]
[TD]1235
[/TD]
[TD]PEARS
[/TD]
[TD]CHRIS
[/TD]
[/TR]
[TR]
[TD]1236
[/TD]
[TD]ORANGES
[/TD]
[TD]BIANCA
[/TD]
[/TR]
[TR]
[TD]1237
[/TD]
[TD]ORANGES
[/TD]
[TD]BIANCA
[/TD]
[/TR]
[TR]
[TD]1238
[/TD]
[TD]APPLES
[/TD]
[TD]ANGELA
[/TD]
[/TR]
[TR]
[TD]1239
[/TD]
[TD]BANANAS
[/TD]
[TD]CHRIS
[/TD]
[/TR]
[TR]
[TD]1240
[/TD]
[TD]ORANGES
[/TD]
[TD]BIANCA
[/TD]
[/TR]
[TR]
[TD]1241
[/TD]
[TD]GRAPES
[/TD]
[TD]CHRIS
[/TD]
[/TR]
[TR]
[TD]1242
[/TD]
[TD]ORANGES
[/TD]
[TD]BIANCA
[/TD]
[/TR]
[TR]
[TD]1243
[/TD]
[TD]GRAPES
[/TD]
[TD]CHRIS
[/TD]
[/TR]
[TR]
[TD]1244
[/TD]
[TD]STRAWBERRIES
[/TD]
[TD]TONY
[/TD]
[/TR]
[TR]
[TD]1245
[/TD]
[TD]ORANGES
[/TD]
[TD]BIANCA
[/TD]
[/TR]
[TR]
[TD]1246
[/TD]
[TD]WATERMELON
[/TD]
[TD]JANE
[/TD]
[/TR]
[TR]
[TD]1247
[/TD]
[TD]STRAWBERRIES
[/TD]
[TD]JERRY
[/TD]
[/TR]
</tbody>[/TABLE]

























RESULTS EXPECTED ON NEW SHEET
[TABLE="width: 500, align: left"]
<tbody>[TR]
[TD]A
[/TD]
[/TR]
[TR]
[TD]PEARS
[/TD]
[/TR]
[TR]
[TD]GRAPES
[/TD]
[/TR]
[TR]
[TD]BANANAS
[/TD]
[/TR]
</tbody>[/TABLE]







In my example APPLES, ORANGES, STRAWBERRIES, or WATERMELON did not show on the new sheet becuase alll of the child values (column C) does not say "CHRIS" for the related parent values (Column B).

EXTRA: It would be great to have a version that creates a list on a new sheet without defining the child value (column C) I’m looking for. It would always list the parent value (column B) if the child values (column C) are the same regardless of what the text says.

RESULTS EXPECT FOR EXTRA VERSION
[TABLE="align: left"]
<tbody>[TR]
[TD]A
[/TD]
[/TR]
[TR]
[TD]PEARS
[/TD]
[/TR]
[TR]
[TD]GRAPES
[/TD]
[/TR]
[TR]
[TD]BANANAS
[/TD]
[/TR]
[TR]
[TD]ORANGES
[/TD]
[/TR]
[TR]
[TD]WATERMELON
[/TD]
[/TR]
</tbody>[/TABLE]










In this version ORANGES and WATERMELON was added to the list becuase all parent values (Column B) has the same child value (Column C).
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi

You need to use Advanced Filter.
I named your three columns on Math as Code, Type and Name
On sheet complete, enter Name in A1 and Type in A5
Then, add the following event code to your sheet complete
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$A$2" Then Exit Sub
    Application.ScreenUpdating = False
    Call FilterData
    Application.ScreenUpdating = True
End Sub

Then Insert a code module and copy this code into it
Code:
Sub FilterData()
         Sheets("Math").UsedRange.AdvancedFilter Action:=xlFilterCopy, _
        CriteriaRange:=Sheets("Complete").Range("A1:A2"), _
        CopyToRange:=Sheets("Complete").Range("A5"), _
        Unique:=True
End Sub

Remember to save your file as a .xlsm or a .xlsb file as it will now contain macros.

Now, if youenter Chris in A2 on sheet Complete, you will see a list of Apples, Pears, Bananas, Grapes.
If you delete any entry in A2 and press Enter you will see the complete unique list
 
Upvote 0
Hi

You need to use Advanced Filter.
I named your three columns on Math as Code, Type and Name
On sheet complete, enter Name in A1 and Type in A5
Then, add the following event code to your sheet complete
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$A$2" Then Exit Sub
    Application.ScreenUpdating = False
    Call FilterData
    Application.ScreenUpdating = True
End Sub

Then Insert a code module and copy this code into it
Code:
Sub FilterData()
         Sheets("Math").UsedRange.AdvancedFilter Action:=xlFilterCopy, _
        CriteriaRange:=Sheets("Complete").Range("A1:A2"), _
        CopyToRange:=Sheets("Complete").Range("A5"), _
        Unique:=True
End Sub

Remember to save your file as a .xlsm or a .xlsb file as it will now contain macros.

Now, if youenter Chris in A2 on sheet Complete, you will see a list of Apples, Pears, Bananas, Grapes.
If you delete any entry in A2 and press Enter you will see the complete unique list


I tried this and it doesn't seem to be working. It's copying the entire worksheet from 1 to the other.
 
Upvote 0
It sounds as though you didn't enter the word Type in cell A5 of worksheet Complete


Got it! I <g class="gr_ gr_91 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="91" data-gr-id="91">missunderstood</g> and actually entered the name and type of item I wanted to see. It worked perfectly when I entered the actual word "Type". Thank you for the help.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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