Filter range in a formula - excel

Is it possible to filter a range in a formula ?
E.g., I have cells with data validations (dropdowns). Data validation refers to named ranges. Named ranges are based on 'tables'.
First dropdown is product. If first dropdown has selected a value (e.g., wheels), the second dropdown (dimensions [of wheels]) should show only wheel dimensions and not all dimensions of all products.
(Of course, my dimension table has also the column product.
I'd like to filter a named range in the formula so I can set it in the data validations. Ideally, I don't want to use macros.

You can achieve this with helper table. For each additional hierarchy you will need to add additional helper table. So for instance if have first drop down in cell G1, and helper table in columns A:B, select cell H1, set data validation ==> list, and in formula part enter this formula =OFFSET(B2,MATCH($G$1,$A$2:$A$3000,0)-1,0,COUNTIF($A$2:$A$3000,$G$1),1)
Now drop down in cell H1 id dependent on drop down in cell G1.

Related

How to remove a value (from the adjacent cell) in the drop-down list?

I have two columns Product 1 and Product 2, both of which lets user select from a dropdown list. But I don't want to show the same value in Product 2 if the user selected it for Product 1 in the same row.
The formula I am using for the drop down list is:
='Details'!$C$2:$C$500
If helper columns are allowed drop this formula into D2 and drag down:
=IF(C2=PRODUCT1,"",C2)
I don't know what cell the first dropdown is, just plug that cell ref in where I said PRODUCT1
, make sure to use $ to lock the cell ref. (ex. A1 become $A$1)
Then select your second drop down and set its data validation to ='Details'!$D$2:$D$500
It will leave a blank where the value used to be.

Excel vba : Synchronize two drop down lists in the same worksheet

I'm starting to use Excel VBA to create drop down lists using data validation but i would like to synchronize two drop down lists in the same worksheet.
I created the first list which is 1, 2, 3, 4, 5 and I created the second list which is A, B, C, D, E
My purpose is when I choose Item number 3 from the first list (which is 3) automatically the Item number 3 (which is C) from the second list will be displayed.
I tried to use the INDEX and MATCH fct but without success could you please help me with that
Thank you for your help
Hichem.
If you have a data validation drop-down in a cell, you shouldn't have a formula in that cell at the same time. As a rule, a cell should either be calculated or used for data entry, not both.
Using a formula, you can put the values you want to calculate in the second cell into the spreadsheet somewhere, if they are not already. Then you can use a simple Vlookup or Index/Match. For example, all drop-down list options are stored on a sheet called Setup. The values for the second data validation list are in the cells C2 to C6. The values for the first data validation list are in cells A2 to A6. You can now use the value selected in the data validation list like this:
=index(Setup!$C$2:$C$6,match(Sheet1!C2,Setup!$A$2:$A$6,0))
In words: in column A of the setup sheet, find the value that is the same as C2 in Sheet1 and return the value from column C of the setup sheet in the same row.

Excel validation dropdown - populate with relevant values based on category

So I have two categories - lets call them 'Cars' and 'Vans'. The first sheet in the workbook has a list of vehicles with the category name in the cell to the left:
CATEGORY VEHICLE ID
Car 12987
Van 28374
Van 34872
Car 38747
Car 48726
I want to use that list elsewhere in the workbook to populate validation dropdowns. Is there a way to pass a category name (i.e. Vans or Cars), search the left column for cells that match that value, then where there are matches populate the dropdown with values from the adjacent ID column?
Data Validation will only accept ranges, not arrays, and the ranges have to be contiguous, so you'll have to use a helper range or sort by CATEGORY. To replicate the results shown in the images, follow the steps below.
Enter this as an array formula in C2 (ctrl+shift+enter) and fill down:
=IF(COUNTIF($C$1:C1,C1)<COUNTIF($A$2:$A$6,C1),C1,INDEX($A$2:$A$6,MATCH(0,COUNTIF($C$1:C1,$A$2:$A$6),0)))
Enter this in D2 (again as an array formula) and fill down: =INDIRECT("B"&SMALL(IF($A$2:$A$6=C2,ROW($A$2:$A$6)),COUNTIF($C$1:C2,C2)))
Enter this as the Data Validation list formula in G2, then fill G2 down to G3:
=INDIRECT("D"&MATCH(F2,$C$2:$C$6,0)+ROW($A$1)&":D"&MATCH(F2,$C$2:$C$6,0)+COUNTIF($A$2:$A$6,F2)+ROW($A$1)-1)

How to write and run excel function in data validation ms-excel

I have an Excel sheet as below-
Cell No / Column A
-------------------
1. Total
2. $1,350.00
3. $2,670.00
4. $2,891.00
5. $1,107.00
6. Drop-Down List
I have added Data Validation List with some function name like MIN, MAX, SUM.I want to calculate the value of A2:A5 cell and display in A6 cell, if i select any of one function in A6 cell, which is added through data validations. Suppose I select SUM form in A6 cell, it will show sum of value function like SUM(A2:A5).
How can I do that?
You can simply create these three formulas in Column B, say, MIN in B1, MAX in B2, SUM in B3.
Then pull your data validation drop down list from these cells which already contain that formula.
However you need to format your B1, B2, B3 cells so that in data validation list you see for example MIN, MAX or SUM. I have done this for you in this dropbox link
like this:
here is the preview
You can hide column B so that nobody can make any changes to it. I have also selected the entire column range in column A in the formulas so if you add anything later to that column it automatically calculates them alL.
You can add as many formulas to column B as you want,and then put them in your data validation dropdown menu. Don't forget to format your cells in column B. You should custom format it and put your desired text inside "", like "MIN PRICE".

How can I write a database like query in excel using just functions?

I have some data that's structured in a table like this:
.
I have another tab on my spreadsheet where I eliminate any duplicate category entries and want to concatenate the data to look like this:
I need to create this using a function and not a macro or Visual Basic. I've already written the function to eliminate any of the duplicate category entries and now I need to figure out how to take each of those unique categories and append the data behind it. Any ideas?
Assuming the first image comes from Sheet1 and the second Sheet2, here's a way to do it. You need to add at least one calculated column to Sheet1 and optionally two calculated rows to Sheet2.
Uniquely identify each row on Sheet1. Add a new column A with the formula =B3&COUNTIF($B$3:B3,B3) in A3 and fill down. You'll have first1 in A3, first2 in A4 and so on.
Identify each block of columns on Sheet2. Add a new row 6 with the formula =COUNTIF($B$2:B2,B2) in B6 and fill across. The values will be 1,1,1,2,2,2,3,3,3. You can type these in manually if you like but it won't scale as easily.
Work out the column of each data item in Sheet1 and put in the columns for Sheet2. Add a new row 7 to Sheet2 with the formula =MATCH(B2,Sheet1!$A$2:$E$2,0) and fill across. The values will be 3,4,5,3,4,5,3,4,5. We now know, for each cell in Sheet2, which instance of the category we have and in which column the data variable comes from.
Use VLOOKUP to find first1 and return data column 3 within the data table. On Sheet2, set cell B3 to =VLOOKUP($A3&B$6,Sheet1!$A$2:$E$8,B$7,FALSE) and fill down and across.
You'll have a number of #N/A errors (e.g. cell E4). If you have a newer version of Excel, you can use IFERROR() to escape this; otherwise, use =IF(ISNULL(<formula>), "", <formula>) where <formula> is the formula in step 4.
To summarise:
Create a unique, sequential, calculable row ID for each row in the source.
Determine which instance of that sequence is used by each column in the destination. This is appended to the end of the category to determine the row IDs formed in the previous step.
Determine which column contains the data for each column in the destination.
Look up the row with the calculated row ID and find the relevant column for this data item.
Format the results appropriately.

Resources