I wrote a formula for an excel data constraint that works in a cell. Using this formula for an excel data constraint always evaluates to false which means I keep getting an error in my custom formula for my data constraint.
I'm stuck since the formula works in a cell but not in a custom data constraint. I want the formula to only allow input that is in another table. So when a user types in a value it will give an error if it doesn't exists in another table.
Here is my formula so far
IF(ISERROR(VLOOKUP('Table1'!A14, Table2[#All], 2,
FALSE)),FALSE,TRUE)
Table1 is the table I want the data constraint on. Table 2 column 1 is the table I want to check if the value I enter exists in there. If the value doesn't exists in another table then I want to block the user from entering data into that cell.
Problem is formula in validation is not taking Table as range. So, use named range instead of Table. See the below formula. Here MyRng is a named range of range Sheet1!$F$3:$G$8
=IF(COUNTIF(INDEX(MyRng,,1),B3)>0,TRUE,FALSE)
Related
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)
I'm trying to insert specific formulas and values across a row depending on the value from a drop down box rather than manually inserting these formulas and defeating the purpose of the drop down.
Edit: I used the Data validation to create the drop down, but I'm using this for an accounting purpose. So the drop down will have the type of transaction and I'm wanting the defined formulas used for that specific transaction to insert across the row. Below is part of my data sheet, and I want the formulas corresponding to the transaction type to be inserted into my other sheet where the drop down is, and have the formulas correspond with the drop down response.
If I get your question right, you can use "Data Validation" for this task:
In the example above, the range A2:A7 defined as List, and I refer to it in the Data Validation dialog. In the range List you can place any formula you like.
Is this what you are looking for?
After searching, I understand I can copy data into a table one at a time using VLOOKUP. However, is it possible to replace an entire table with another if a cell contains a certain value?
For example,
I have a table1. I want to replace table1 with table2 if cell a1="table2"
The reason is I will have many tables and depending on what I put in a cell, A1, I want table 1 to be what ever table I choose. I also want it to be easily updated when I add even more tables.
Edit for more information:
I have one table lets call it table1. Another table, Table2, with columns Name and Values. Also I plan on having more tables, so Table3 with columns Name and Values. I have a cell somewhere on the page, or another page. If I write Table2 in this cell. I would like the entire Table1 to be replaced by table2. Ultimately copying the data in.
I have tried structured tables, but it only copies from the same row. If I put it in another row, i get null basically. Vlookup, I think requires me to have a formula for each row of the table. I might be using this formula wrong.
Without knowing more, one solution is INDIRECT().
Example workbook sheets:
Table1
Table2
Table3
Assume all Table# tabs have the same cell range.
Make a new tab Input:
[A] [B]
[1] User Input
[2] Table # 1
[3]
[4] Reference ="'Table"&B2&"'!"
The formula in B4 evaluates to 'Table1'!. Note that the sheet reference includes the apostophes in case the sheet name has spaces.
Make a new tab Summary Table:
[A]
[1] =INDIRECT(Inputs!$B$4&ADDRESS(ROW(),COLUMN()))
This formula displays the value in the specified sheet name (from Inputs!B4) and the current row and column (so when this formula is entered in A1, it will display the value of Table1!A1). Then fill this formula across the rows and columns necessary to display the table specified in the Input tab.
Note of course that you could combine the Input and Summary Table tabs, but you would need to adjust the ROW() and/or COLUMN() formulas. This is also the case if your source tables do not begin in cell A1.
I have an Excel workbook, with many pivot tables on each sheet. I'm using the pivot tables to display lots of "counts" from my analytic table on another sheet. For example, if the attribute A three levels each, I'm making tables of how many rows fall into A1, A2, and A3.
I also need to create separate, non-pivot tables, which reference the original pivot tables in order to fill in the values which are missing from them. So from the above example, if there are currently no rows with attribute A2, that row wouldn't exist in the pivot table. However, later when I get an updated data sheet I can expect there to be rows with attribute A2. I'd like to create a reference in my second table which can evaluate to 0 when there is not a row for A2 in the pivot table, but when everything gets refreshed takes on the now existing value for A2.
When I try to reference the row using GETPIVOTDATA, I get #REF! if the cell doesn't exist in the pivot table. Essentially, I've just had trouble figuring out how to say:
if (GETPIVOTDATA equals #REF!)
cell equals 0
else
cell equals GETPIVOTDATA
Maybe =IFERROR(*your formula*,0). In other words, if your formula returns an error display 0.
IFERROR detects #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, or #NULL! but if coming from a PT that might be acceptable, though not exactly what you ask.
You can test it by =ISREF(...) or =ERROR.TYPE(...) (should be equal 4 for ref type error) formulas.
I am getting data from PowerPivot to an Excel table. It has variable length. I also have some calculated columns next to it. I would like to make a diagram out of it.
The problem is, as I specify the data ranges and such, I have to oversize, in case the data returned provides more rows. (Ex. in this case i have data till a20, but in an other case I could have data till a30 or more. So I select the range to a40 to be safe.) I have to specify this manually (not select from the pivot table) because of the calculated columns and other labels and exceptions.
In the diagram, it shows these blank rows. This is unnecesary.
How can I instruct excel, not to display those rows, that are blank? (Even if I delete all formulas, and the rows are completely blank, it still displays it.)
Thanks for the help. Sziro.
When I have been facing a similar problem, I have created named dynamic ranges, and made the diagram refer to these ranges.
Here is how I create a dynamic range for a data series stored from range A2 to A40 in Sheet1.
Define a name for you dynamic range using a formula like this in the "Refers to" input box:
=OFFSET('Sheet1'!$A$2,0,0,COUNTA('Sheet1'!$A$2:$A$40),1)
Now make your series value refer to the name you have given the dynamic range. If you have named the range "Sales" you should make the diagram series values refer to: "='Sheet1'!Sales". It is important that you also refer to the name of the sheet, otherwise it won't work.