Validation list using some values in a table

Paul_K

New Member
Joined
Sep 1, 2016
Messages
29
Hello,
I have a table, something like:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Column 1[/TD]
[TD]Column 2[/TD]
[/TR]
[TR]
[TD]Adam[/TD]
[TD]Orange[/TD]
[/TR]
[TR]
[TD]Ben[/TD]
[TD]Blue[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD]Orange[/TD]
[/TR]
[TR]
[TD]David[/TD]
[TD]White[/TD]
[/TR]
</tbody>[/TABLE]

I want to use a list type validation in another range with the list values being where Column 2 = Orange, so the list would be:

Adam
Charlie

I've Created a named range for both _Column1 and _Column2 and tried the formula:
=COUNTIFS(_Column1,A2,_Column2,"Orange")
WHich doesn't work and I'm not sure where to go from there.

Am I even close?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
[TABLE="class: grid, width: 500"]
[TR]
[TD]Column 1
[/TD]
[TD]Column 2
[/TD]
[/TR]
[TR]
[TD]Adam
[/TD]
[TD]Orange
[/TD]
[/TR]
[TR]
[TD]Ben
[/TD]
[TD]Blue
[/TD]
[/TR]
[TR]
[TD]Charlie
[/TD]
[TD]Orange
[/TD]
[/TR]
[TR]
[TD]David
[/TD]
[TD]White
[/TD]
[/TR]
[/TABLE]

Paul_K,
Why not just select the range A1:B4, then using the 'Insert' in the top ribbon, select 'Table'.
Then using the drop downs in the Table you have just created, select 'Orange' (First you have to deselect 'All' then select 'Orange') and the two names are displayed in column A beside 'Orange' in column B.
To see the complete list again just select 'All' from the drop down in column B. No formulae needed.
Perpa

Excel Workbook
ABC
1Column1Column2
2AdamOrange
4CharlieOrange
6
Sheet1
 
Last edited:
Upvote 0
It's not that I want to filter the table, I want to use the values in A in a validation list for another table, but only the values of A should be in the list where B=Orange.
 
Upvote 0
It's not that I want to filter the table, I want to use the values in A in a validation list for another table, but only the values of A should be in the list where B=Orange.

Paul_K,
A simple way to do that would be to make C2 a drop down list, like this:
- Select cell C2 then
- Select Data>Data Validation> Allow: List, Source: =OFFSET($B$2,0,0,COUNTA($B:$B)), then 'OK'
That makes each item in column B selectable. The formula also allows the list to be added to.

Then copy and Paste the code below into a Worksheet module, not a standard code module, like this:
- Right click the sheet tab at the bottom of the sheet and select 'View Code' to open the VB Editor
- Then select the down arrow opposite 'General' and select 'Worksheet'
- Then paste the code below right over the 2 default lines shown so only the code below is there.
- Then close the Editor window and save the workbook as macro enabled.
If you close the workbook you may have to enable macros to activate the macros again, depends on the version of Excel. Now when you select something from the drop down in C2, you get the list you were looking for in column D.

See if that is closer to what you had in mind.
Perpa

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastBRow, LastDRow, Row As Long
    
    If Target.Address = "$C$2" Then
        Value = Cells(2, "C")
    'CHECK IF SELECTION IS MULTIPLE CELLS OR JUST CELL C2 THEN
    'COMPARE VALUES IN COLUMN B to CELL C2, IF MATCH, PLACE VALUES FROM COLUMN A IN COLUMN D
    
        If Target.Cells.Count > 1 Then Exit Sub
        LastDRow = Cells(Rows.Count, "D").End(xlUp).Row + 1
        Range(Cells(2, "D"), Cells(LastDRow, "D")).ClearContents
        LastBRow = Cells(Rows.Count, "B").End(xlUp).Row
        LastDRow = 2
        
        For Row = 2 To LastBRow
            If Value = Cells(Row, "B") Then
                Cells(LastDRow, "D").Value = Cells(Row, "A")
                LastDRow = Cells(Rows.Count, "D").End(xlUp).Row + 1
            End If
            
        Next Row
    End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

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