I am trying to do a data validation list where the drop down only contains text like "US" or "EU" to isolate the PO numbers. The table column I am pulling from can have things like "US12345" or "EU76543" or "ID10987". I need the list to only show the items that have that US in them.
I tried:
=IF(INDIRECT(Table[PO_Number])="US*",INDIRECT(Table[PO_Number]),"")
This gives a Value Error.
Is what I am trying to do possible? If so, how?
You'll need to create the desired filtered list somewhere within the workbook, as dynamic lists cannot be entered directly within Data Validation.
For example, assuming you have Office 365, this formula in cell D1:
=FILTER(Table[PO_Number],LEFT(Table[PO_Number],2)="US")
will spill all matching entries.
(Amend the condition - here checking if the initial two letters of the PO Number are "US" - as required.)
For the Data Validation, you can then use the List option and set the Source to:
=$D$1#
Include the sheet name in the above expression if the cells being validated are not in the same sheet as the FILTER formula.
Related
I want to filter a table in excel and return a different column to create a list for data validation.
My table contains a list of names and one of the columns is a Yes or No for being an admin.
I want to create a data validation list on another sheet and use the filter table to just show those names that have a Yes in their associated row in the table.
I recorded a macro to filter the table to show just the rows I need and now want those names to appear in the list.
ActiveSheet.ListObjects("Staff").Range.AutoFilter Field:=8, Criteria1:="<>"
Is this possible?
I had tried using the =FILTER() formula but it's not available in my version of Excel.
I'd prefer to do it with a formula in the validation settings rather than VBA.
This is something of a faff but I think it works, though by no means the best way of doing it.
Table of data on the left.
The "Yes" names are listed in D1 and down, the formula is an array (use Ctrl, Shift and Enter to confirm). I'm sure someone cleverer than me can shorten this.
=IF(ROWS(D$1:D1)<=COUNTIF(Table1[Admin],"Yes"),INDEX(Table1[Name],SMALL(IF(Table1[Admin]="Yes",ROW(Table1[Name])-ROW($A$2)+1),ROWS(D$1:D1)),1),"")
E1 is just the total of the names shown in D (another array formula):
=SUM(IF(LEN(D:D)>0,1,0))
The DV is in G1 and the formula there is
=OFFSET(D1,0,0,E1,1)
If you change e.g. Sarah to Yes, her name will appear in D and will be added to the DV list.
Once you've applied your filter to column 8, you can select the range that remains visible in a different column using:
ActiveSheet.ListObjects("Staff").Range.Columns(8).SpecialCells(xlCellTypeVisible).Offset(0, -2)
This would return a range consisting of column 6 (8-2) of your table. Adjust to suit your needs.
You could then cycle through that range one cell at a time and populate a new range from it, accordingly.
I am trying to piece together some VBA code that would apply data validation (creating a list to use) to a cell based on the value of the cell next to it. I have this functionality working in a Google Spreadsheet which I just linked but I don't know anything about VB so I'm struggling with this.
The layout is a little odd with the spreadsheet since the sheet(s) that need this validation have the headers of the rows starting at row 2.
The basics of what's going on is:
The header of the column that is determining the validation is called "Attribute Group". I want to avoid needing a fixed position so I went with the header name instead of a column index
When a value changes in "Attribute Group" the cell adjacent to it to the right will have a dropdown created with values corresponding to the value in "Attribute Group"
Please check out the linked spreadsheet to see this functionality in action. I'm trying to get as close to this as possible in Excel.
Edit: The main question is: how do you create dynamic data validation in Microsoft Excel?
Unfortunately I don't have time to get this working exactly as I would like.
The solution I have now was to create tables for each column that had data that would correspond with the appropriate "Attribute Group".
Insert > Table
Rename table to match corresponding "Attribute Group" value, removing spaces and special characters
Remove duplicates to get rid of most blank cells then Resize Table if needed to get rid of any others
Then I added data validation in cell E3 using =indirect() as well as substitute() since my "Attribute Group" values had spaces and special characters.
Data > Data Validation
Under "Settings" I used "List" in the Allow section
The source was =INDIRECT(SUBSTITUTE(SUBSTITUTE($D3," ",""),"&","And"))
Then I copied cell E3 and pasted all the way down.
This method solves my current issue but doesn't allow for the level of flexibility that I was hoping to accomplish.
Use a named range (Eg "MyDataRng") for the range of cells in the Attribute Group then in a list type data validation enter =MyDataRng
My question is , in excel when we create a dependent dropdown we write the formula for the other dropdown dependent on the first one. For example if USA is selected in first col the matching City of USA will be pulled and then can be populated in a data validation list.
I know how to write formula to get the items matching criteria. My problem is what if we have multiple dropdowns .
For example we have 100 rows with column A for selecting Countries and then next to each of these we have dropdown for selecting City.
Do I need to write 100 formulas for these dependent dropdowns or there is another way around to achieve this?
Consider the following,
The data validation lists in A2:A10 are based on a List with a Source: of,
=$AA$2:$AA$5
The data validation lists in B2:B10 are based on a List with a Source: of,
=INDEX($AB$2:$AE$6, 0, MATCH($A2, $AB$1:$AE$1, 0))
sample workbook
I have two tables that get dynamically created from a database query; the first table is the source of the drop-down list, and the second is the table that I will apply the drop-down list via data validation. First table:
and the second table:
What I need, ideally through just Excel formulas, is an intelligently designed drop-down that shows only the dimension values associated to the dimension in question.
So in cells B3:B10, the drop-downs would show a,b,c. In cells C3:C10, the drop-downs would show 1,2,3. In cells D3:D10, the drop-downs would show x,y,z. Etc, etc.
I need this to be dynamic in the sense that a week from now my DB query may return a fourth dimension that would need to follow the same approach.
Not sure if this is even possible without writing some VBA, but I figure I'd see if anybody has any creative ideas. Cheers!
You have to use Name Manager and =INDIRECT() formula to achieve that.
First download the sample file.
Sample File
See this tip (By me). It will help you to see screenshots step by step. Link is here
Now in-case of your data you have to use some formula to filter data automatically when new data come. So that new data can organize for dynamic combo boxes. I can also do that for you if you are not able to do that. Then share your sample workbook with me.
It is very possible, but not simple. There are a several ways to implement this, depending on your requirements, how dynamic it needs to be, and the expected structure of the data (as I mentioned in a comment).
I will give one possible solution, that is mostly dynamic, and is the simplest to explain. You can use a similar logic to make it all dynamic.
This solution will retrieve the data from table #1 according to the dimension name, assuming it is not sorted, and return the values in the order they are given in the table.
For some of the ranges I create names for simplicity, and some are mandatory. In order to follow the formulas logic you need the named ranges I use.
Create named ranges for table #1: (Either by using the Name Box or using the Name Manager Ctrl+F3):
For the data in the column Dimension: DimName =B3:B11
For the column Dimenstion Value: DimValue =C3:C11
Create dimension values lists in a new sheet:
Put the dimension name in B2 ="Customer". (The available dimension names can be created dynamically as well, but I'm skipping this part for simplisity).
B3 (array formula - Ctrl+Shift+Enter) =IFERROR(INDEX(DimVal,SMALL(IF(DimName=B$2,ROW(DimName)-ROW(INDEX(DimName,1))+1),ROWS(B$3:B3)),1),""). This formula returns the k-th value for the "Customer" dimension.
Copy B3 down to as many rows you think you'll need. Let's say B4:B10, so B3:B10 will have the array formula. The first cells will have the available values and the remaining cells will be empty because of the IFERROR function.
In B1 we will count the available values using the formula =SUMPRODUCT(--(B3:B10<>"").
Do the same for "Product" and "Geography" in columns C and D.
Create dynamic named ranges for the lists: (using the Name Manager Ctrl+F3)
For the lists' data DimLists =B3:D10.
For the lists' headers DimListHeaders =B2:D2.
For the lists' counts DimListCounts =B1:D1.
*These names are mandatory for the data validation to work in another sheet.
Set table #2 data validation list sources:
Select B3:B10 in table #2.
Go to Data > Data Validation, and select Allow: List.
Put the following formula in the source: =OFFSET(INDEX(DimLists,,MATCH(B$2,DimListHeaders,0)),,,INDEX(DimListCount,,MATCH(B$2,DimListHeaders,0))). This formula finds the correct list in DimLists according to the column header in table #2, and also sets the returned range height according to the list count.
Hope this helps.
I have to filter below given excel sheet by a list of 'ID's.
My excel sheet contains thousands of 'ID', in which i have to filter only a particular list of 'ID's. It will take time if I enter values in the list one by one, now how can i filter the list of 'ID's at a time? For example in the above excel sheet how can I filter the list {3,4,11,19}?
You can use Data > Advanced Filter to filter the list. You need to enter the filter criteria in one or more cells. These cells must have the same column header as the column you want to filter on. Typically, these filter criteria cells are created in empty rows above the table, but they can be anywhere else on the spreadsheet.
Click a cell in the data table, select Data > Advanced Filter. Select the filter range and tick to filter the list in place.
The result looks like this:
Note how the blue row headers indicate that there are hidden rows. You can clear the filter by hitting the "Clear" button on the ribbon.
In general you wouldn't be filtering on a list of ID, the whole idea of ID's is for a unique identifier for each row of data making it unique from each other.
You would normally have other columns of "category", "sub category" etc to make the data meaningful.
But saying that , you can use vba to allow you to enter a list of numbers to filter for you.
Create an input box where you enter a list of comma separated values
use vba to create an array of these numbers ,
then set the auto filter with
Criteria1:=Array(var1,var2,var3,var4,etc, "=")
The drawback of Advanced Filter is that you can't display the filter or update it. Each time you want to update it, you must define the Advanced Filter from scratch.
Another solution (which also has some drawbacks) is to create a new filtered range with a formula like this one (inspired from this one-column solution):
=FILTER(A6:D25,NOT(ISERROR(MATCH(A6:A25,Sheet1!A1:A4,0))),"")
Example: