Excel Data Validation Source for different columns - excel

I am making a series of cascading dropdowns in Excel. When a user selects an option in ColumnB, the sheet finds a list "Name"d = ColumnB value and set the validation for that column with that list.
It is working fine
But when I drag the cell in the whole column and try applying the Data Validation property to all cells, instead of selecting the previous cells respectively, it is defining every Data Validation property with the specific cell with which the first cell was binded.
It is not much of a problem as I can do that for individual cell, but I will be setting the data and names through code later, so I need to find a way that every Data Validation source contains a reference to its previous cell instead of that one specific cell.

Remove the $ sign. $ sign means that the reference is absolute and the cell reference in the formulas won't change when the cell is dragged or copied.
Another solution is to define the data validation for the entire column and you don't have to drag anymore.

Related

Having trouble with an Excel formula in the data validation window [duplicate]

Whenever I do a dependent dynamic drop down list , I see a bunch of blank cell in the drop-down list , I search many topics that explain how to remove them while by adding two additional ranges like explained her http://blog.contextures.com/archives/2014/02/27/dynamic-list-with-blank-cells/
but my question is: Is there anyway to avoid blank cell or remove them using a simple approach without the need of two additional ranges or a complex formula?
the drop down list that contains blank cell all I did is go to data validation and wrote in source =MYCode then I named the list that contains the codes like that MyCodeand I checked ignore blank case (even tho It seems to be useless )
There is another way. Create a dynamically-expanding named range. Then use the range to define the data validation list.
To create your dynamically-expanding range, insert this in the named range box and give it a name:
=OFFSET($A$1,0,0,COUNTA($A:$A),1)
$A$1 should be replaced with the top cell of your range. $A$A should be replaced with the column(s) the range is in.
OFFSET points the named range at a range of cells. COUNTA() is in the fourth position of the OFFSET formula, which sets the height of the range. It counts the number of non-blank cells. As a result, when you add a value, the fourth value of the OFFSET formula increases and you get an expanding range.
Note, this does not work if your named range has blank cells interspersed.
OFFSET formula from excel-easy.com.
After some more research I found a solution. In the cell where my information is filled I added a name using the name Manager and I added this formula that I adapted from this article:
=DropList!$J$1:INDEX(DropList!$J$1:$J$10000,SUMPRODUCT(--(DropList!$J$1:$J$10000<>"")))
It did what I needed without the need of adding 2 extra cell, even though the line of code is rather complex.
I know this thread is dead but I found a simpler solution which only requires you to create a single named range. It also works even if blank cells are interspersed in the source data, and expands as the source data expands.
First create your dynamically expanding named range using the formula given above:
=OFFSET($A$1,0,0,COUNTA($A:$A),1)
This will includes the values you want in your drop-down, as well as blank cells.
Next, in a separate cell, enter the following:
=FILTER(Your_Range, Your_Range <> "")
The result will be your source data with no blanks. This will spill into adjacent cells. Now can reference this single cell as your data validation list, as long as you add "#" to the end of the cell reference. This tells excel to include all the spilled values in the list.
Benefits:
If your source data named range is dynamic, the drop-down list will expand with this range, and you don't have to worry about updating a second named range.
You can easily filter more data, and it doesn't matter if blank cells are interspersed.
Combined with the SORT and UNIQUE functions, you can further improve how your data is represented in the drop-down list.
I couldn't find a solution this simple anywhere else, so I hope someone finds this useful.
If there are no empty cells within the source list, but the empty rows come from the end of the list, you can get rid of those by using a table as the source of the dropdown. You have to use the INDIRECT function to refer to the table:
Select the whole source list including the header
Click Format as table
Select the table, go to the Design tab (under Table Tools)
Rename the table
Select the cells where you want to use the dropdown and open the Data Validation
As the dropdown source, set: =INDIRECT("TableName[ColumnName]") (note the double-quotes)
This article explains the procedure in more detail

Excel - Dynamic Dropdown List

Looking to make a dynamic dropdown list in a table. The photo link below should help visualize the problem.
What I am looking to do is create a dynamic dropdown list in one table using a column from the same table and two columns from a second table in another sheet.
The column with the dropdown should compare the column to the left of it to right column of the second table. The options in the dropdown should be the values in the left column of the second table if the cell to the left of the dropdown cell equals the cell to the right of the value cell in the second table.|
The photo below shows the table setups and the numbers next to the top left table show what options that should be in the dropdown.
Edit: I was looking to do this without using Visual Basic, but I would be open to it if it were the only option.
This is called dependent data validation. You need to set up range names. One for each reference, and an additional one to resolve the reference into a dropdown using Indirect. I set up these four range names and for the data validation I used List > =MyDropdown
a =Sheet1!$H$2:$H$5
b =Sheet1!$H$6:$H$8
cc =Sheet1!$H$9
MyDropdown =INDIRECT(Sheet1!$A2)
Note that the reference inside the INDIRECT() function is relative to the cell that was active when the reference is defined. Select cell in row 2, then create a new named range with that formula. If you select another cell, this will not work.
Note also that the named range cannot be called 'c', so I had to use another reference name.
As per above data setup put below formula to H6
=TRANSPOSE(UNIQUE(E6:E13))
Then put below formula to H7 cell and drag across right.
=FILTER($D$6:$D$13,$E$6:$E$13=H$6)
Above formulas will spill data automatically. Then in data validation for range A1:A10 put below formula
=H$6$#
# after H$6$ will take data dynamically output by Unique() formula till last data.
Then for range B2:B10 data validation formula will
=INDEX($H$7:$J$10,,MATCH($A1,$H$6#,0))
Dropdown result

Selecting a Specific Column of a Named Range for the SUMIF Function

I am trying to create a SUMIF function that dynamically adds up values in a specific column of a named range in my Excel sheet.
It is very easy to do this when there is no named range :
The formula picks out all the cells that contain "London" in their name and sums up the expenses related to London.
What I am trying to do is to use a named range called TripsData (A2:B5) and tell the SUMIF function to sum the entries in the column 2 of this range that meet the criterion of having London in their name.
How can I make this work without needing to create a second named range for column 2 and simply by telling Excel to look within the specified column of this named range? Index/Match only return one value so that doesn't work when there are several cells with London in their name.
Thanks for your help!
Use INDEX to refer to a specific column in the named range (it can refer to a whole column), like this
=SUMIF(TripsData,"*London*",INDEX(TripsData,,2))
You can do that without any named ranges at all, if you turn your data into an Excel Table object. Select any cell in the range or the whole range and click Insert > Table or hit Ctrl-T.
There will be a dialog that asks if your table has headers. Yours does. Now you can reference the table and its columns by their inherent names and build your formula like this:
=SUMIF(Table1[Expense],"*London*",Table1[Cost])
You can rename the table, of course, even after the formula is in place. When you click a cell in the table, there will be a new ribbon for commands that relate to tables only. It's a very powerful tool.
Any formulas, formatting etc. that apply to a whole table column will automatically carry over into new table rows. The table column reference will adjust automatically, too, of course, so you don't have to mess with dynamic range names or re-define what a named range applies to.
Note: the formula uses structured referencing instead of cell addresses. This option can be turned off by clicking File > Options > Formulas > tick or untick "Use table names in formulas"
You can use Chris' idea of Index(Table1,,Col#) with the named range "Table1" (without creating an Excel table Object if you don't want to for some reason) and STILL avoid the problem Applez mentions in the comment below Chris' idea. Applez warns that using a constant for a column number reference is dangerous if you later insert another column before that column in the named range. You will find that Excel does NOT auto increment the constant, so your formula breaks.
Applez is right..... so DON'T use a constant, use a column number "reference" instead of a constant. For example....
=SUMIF(TripsData,"*London*",INDEX(TripsData,,Column(B1)))
If you later insert a column between A and B, Excel WILL auto increment the reference Column(B1) to Column(C1). Just don't delete B1 or Row 1 or you will get a REF error. I usually use the the header/tile "cell" (in whatever row that is in) for that table column within the Column reference (as it is highly unlikely I will ever delete the header/title cell of column of a table unless I delete the entire column). In this particular example as it turn out, B1 "IS" the the title/header cell for that column in the data table. So that is what I used for the example.
Awesome formula, just in case anyone needs to use a similar approach to FILTER a range. I used this approach
pmGendHC is the range I wanted to filter (I expect a spilled range with my data) I needed a colum (column number 13) to be different than 0
=FILTER(pmGendHC,INDEX(pmGendHC,,13)<>0)

Simple way to remove blank cells dynamic dropdown list Excel

Whenever I do a dependent dynamic drop down list , I see a bunch of blank cell in the drop-down list , I search many topics that explain how to remove them while by adding two additional ranges like explained her http://blog.contextures.com/archives/2014/02/27/dynamic-list-with-blank-cells/
but my question is: Is there anyway to avoid blank cell or remove them using a simple approach without the need of two additional ranges or a complex formula?
the drop down list that contains blank cell all I did is go to data validation and wrote in source =MYCode then I named the list that contains the codes like that MyCodeand I checked ignore blank case (even tho It seems to be useless )
There is another way. Create a dynamically-expanding named range. Then use the range to define the data validation list.
To create your dynamically-expanding range, insert this in the named range box and give it a name:
=OFFSET($A$1,0,0,COUNTA($A:$A),1)
$A$1 should be replaced with the top cell of your range. $A$A should be replaced with the column(s) the range is in.
OFFSET points the named range at a range of cells. COUNTA() is in the fourth position of the OFFSET formula, which sets the height of the range. It counts the number of non-blank cells. As a result, when you add a value, the fourth value of the OFFSET formula increases and you get an expanding range.
Note, this does not work if your named range has blank cells interspersed.
OFFSET formula from excel-easy.com.
After some more research I found a solution. In the cell where my information is filled I added a name using the name Manager and I added this formula that I adapted from this article:
=DropList!$J$1:INDEX(DropList!$J$1:$J$10000,SUMPRODUCT(--(DropList!$J$1:$J$10000<>"")))
It did what I needed without the need of adding 2 extra cell, even though the line of code is rather complex.
I know this thread is dead but I found a simpler solution which only requires you to create a single named range. It also works even if blank cells are interspersed in the source data, and expands as the source data expands.
First create your dynamically expanding named range using the formula given above:
=OFFSET($A$1,0,0,COUNTA($A:$A),1)
This will includes the values you want in your drop-down, as well as blank cells.
Next, in a separate cell, enter the following:
=FILTER(Your_Range, Your_Range <> "")
The result will be your source data with no blanks. This will spill into adjacent cells. Now can reference this single cell as your data validation list, as long as you add "#" to the end of the cell reference. This tells excel to include all the spilled values in the list.
Benefits:
If your source data named range is dynamic, the drop-down list will expand with this range, and you don't have to worry about updating a second named range.
You can easily filter more data, and it doesn't matter if blank cells are interspersed.
Combined with the SORT and UNIQUE functions, you can further improve how your data is represented in the drop-down list.
I couldn't find a solution this simple anywhere else, so I hope someone finds this useful.
If there are no empty cells within the source list, but the empty rows come from the end of the list, you can get rid of those by using a table as the source of the dropdown. You have to use the INDIRECT function to refer to the table:
Select the whole source list including the header
Click Format as table
Select the table, go to the Design tab (under Table Tools)
Rename the table
Select the cells where you want to use the dropdown and open the Data Validation
As the dropdown source, set: =INDIRECT("TableName[ColumnName]") (note the double-quotes)
This article explains the procedure in more detail

Data Validation Batch Edit

I am trying to create a vocabulary quiz in excel, where a correct answer is the only possible input into a cell. So far, I use data validation to ensure that outcome, but cannot figure out a way to batch edit data validation. I want every blank cell's validation to equal the adjacent cell, which contains the correct answer. I was hoping that copying one correctly formatted cell and pasting it in an empty cell would cause the new cell to reference the new adjacent cell, but have found that the new empty cell still validates according to the old cell. In other words, I would like the cell's data validation to copy and paste sequentially, like when you drag a cell containing the number 1 and the cells below populate with 1, 2, 3, etc.
This is a problem that has to do with efficiency. I could accomplish what I want by data validating every cell to its adjacent "by hand," but it takes a very long time with large amounts of data. I've tried conditional formatting as well--a correct answer turns the cell green--but have run into the same problem.
Any help would be greatly appreciated.
Thanks.
Not sure how you did the copy/paste, but it should work fine. Here is an example.
Set up the initial data validation. I am using the List version of it with a single cell reference. Note that the single cell reference is defined relatively (no dollar signs in it). I removed the In-cell dropdown option so the answer isn't visible!
Now if I copy that cell and paste one cell below, it will apply the data validation with the range updated. I did this with a simple copy of C6 and paste into C7. I changed the value to b after the paste to not get the error. When I open the validation for C7 I see the new range (D7).
You can paste to a larger range than 1 cell and it will update all of the references accordingly.

Resources