Excel Structured Reference Dynamic Table Name - excel

I've been at this for an hour now and I've ended up going back to using INDIRECT, which I would rather avoid. I feel like there must be a simpler way of using table format to get this done very cleanly, but I can't figure it out!
I have a sheet like this, where I want the yellow area on the right to show me the data from the available choices on the left, based on the value in the orange cell at the top. The top table is called tPeople, and the bottom table is called tPlaces. So if tPeople is entered in the cell, I want the data for that table to show up in the yellow area.
At the moment, I've set a Named Range of rPeople and rPlaces to get this working with an indirect, but I'd rather be actually using the table, and not use the indirect if possible.
=INDEX(INDIRECT($E$1),$F2,G$1)
Thanks!

Yes it can be done using OFFSET and INDIRECT on the table name. Here TblName is named range for cell I1. One caveat is that the rPeople and rPlaces table must be on the same row or the formula will return #Value error. Also [ID] [ID] is required to fix absolute reference for the structured table referencing. See here.

Related

How do I prevent a column reference to an external Excel sheet from automatically incrementing?

I am trying to reference a column in an external Excel document in my formula, and then expanding said formula to the right to auto-fill the remaining cells. I have some values in the formula that I want to not auto-increment, which have been locked using absolute references ($), and others that should increment. But when it comes to the references to the external worksheet columns, those increment even though it makes no sense for them to do so.
Consider this formula as an example, with A1 through A* being a series of dates:
=COUNTIFS(external_sheet[date]; ">="&A1; external_sheet[status]; "ACTIVE";)
If I were to expand this formula to the right, it will increment [date] and [status] to the next column in the sheet. I do not want this behavior, but as far as I can tell there is no way to lock down these values as you can with absolute references. I tried adding a $ symbol before the external sheet reference, but that just breaks the formula.
An option would be to do external_worksheet!$A:$A instead, but for my use case it would make more sense to use references to named columns, as the order of columns may change between data files.
Figured it out after some more Googling (and learning that this is called a "structured reference"). Apparently, the syntax is this:
=COUNTIFS(external_sheet[[date]:[date]]; ">="&A1)
This will make sure that date does not increment to the next column name when filling to the right.
Thanks, I hate it.

Excel Vlookup with cell reference

I have a cell range that I named "cell_range" in Excel. I want to extract the fourth row and fifth column from this table. The formula,
=vlookup(4,cell_range,5)
gives me the value I am looking for.
However, I also have the text "cell_range" in cell A1. Instead of typing out "cell_range" in my formula, I want to reference "cell_range" indirectly by referencing cell A1. The formula
vlookup(4,A1,5)
is giving me a "#N/A" error.
How can I indirectly reference the table "cell_range" in my formula?
Use INDIRECT:
=VLOOKUP(4,INDIRECT(A1),5)
While you can use INDIRECT to perform this kind of stuff, I steer clear of it for reasons I've outlined at https://chandoo.org/wp/2014/03/03/handle-volatile-functions-like-they-are-dynamite/
In this particular case I'd use a lookup table and either CHOOSE or INDEX, as demonstrated in the screenshot below:
Note that you need to pre-specify your areas with my approach.
Here's the syntax for CHOOSE
=CHOOSE(index_num,value1,value2,...)
Here’s the translation from Microsoft-speak into Jeff-speak:
=CHOOSE(Which area do you want?, First area, Second area, ...)
If using a dropdown or a cell reference to provide the index_num argument, you simply use a lookup table that converts the output of the dropdown or cell input into an index number that tells CHOOSE which range from the list should be used.
In this example, you’re using this approach to choose which area on the spreadsheet to sum. But CHOOSE and INDEX can be used to do a lot more than that. For instance, you could use them to allow a user to dynamically pick which lookup table to use when doing a VLOOKUP. Or you could let the user dynamically pick which range in which sheet to user for some calculations do. Very powerful stuff indeed!

Excel Performance - INDEX-MATCH combination

I am using excel to create data sets that are used in a vba application later. I am using this formula:
=INDEX(BaseData!$L$2:$L$10000;MATCH(DataSet!D5&DataSet!E5&DataSet!K5;INDEX(B‌​aseData!$B$2:$B$10000&BaseData!$C$2:$C$10000&BaseData!$D$2:$D$10000;0);0))
usually with a range from f.ex.: A2 - A10000, because my data can be differently long and often vary in data selection.
However, this slows my excel extremely down. I switched to manual calculations, but then, when activating automatic again, my excel instance takes extremely long and often crashes.
I also tried to past some data, but when creating a new dataset, I have to pull the formula down again and sometimes through this errors occur in my data set.
Any suggestions what I can do to make the INDEX-MATCH formulas more performant?
I appreciate your replies!
UPDATE
I guess a lot of performance goes away because index-match does not select the exact range, but also counts in blank rows. How to get the exactl range with index match automatically?
As I mention in my comment above, as long as this is a 'regular' formula and not an Array Formula, you may find success simply replacing "A1:A10000" with "A:A". However barring that, you can create a cell which will calculate reference the number of rows of data which you have, and then use that cell to indirectly reference the complete column with data in it.
CALCULATING YOUR DESIRED RANGE
For the following example to work, I assume that: Column A includes an index key in the form of numbers only; Column A includes no numbers in the header and above; and that the index rows are continuous, with no breaks. Start with the following formula:
=COUNT(A:A)
If my assumptions above hold, then this will return the number of data elements in your table. Once we know where this data starts, we can use this COUNT to determine where it ends. Assume your header is in row 2. (I like to include the header so that if you insert a row beneath the header, Excel picks up that you want to include the new row in your formulas).With that in mind, this formula will create the Excel-style reference which finds the last cell in column A which has data in it:
=ADDRESS(ROW(A2)+1+COUNT(A:A),COLUMN(A2),1,1)
Assuming 50 rows of data [which start at row 3, below the header], and all other assumptions above, this formula will return the text result "$A$53".
If you wanted to do the same thing, but instead return the full range in Column A where data exists (from the header to row 53), you could do as follows:
=ADDRESS(ROW(A2),COLUMN(A2),1,1)&":"&ADDRESS(ROW(A2)+1+COUNT(A:A),COLUMN(A2),1,1)
This returns the text string result "$A$2:$A$53", which is a reference to the full index of unique ID values. It will automatically move around as you would generally expect if you insert any rows or columns. Now assume for your INDEX that you want to pull the same data, but for column B, instead. The formula will be exactly the same, except that where I have "COLUMN(A2)" above, replace with "COLUMN(B2)".
REFERENCING YOUR CALCULATED RANGE
So now you have the address of your proper, limited columns - but how do you actually reference those areas in a formula? By using the INDIRECT function. INDIRECT says "Evaluate some specific criteria. It will create a cell reference. Now look at that cell reference." In its simplest form, this could look like this:
=INDIRECT(A1)
Assume that A1 holds the value "B5". Indirect will pick up the value "B5", and instead of displaying "B5", it will go to B5, and pick up the value there. So to use this with the above, wrap the whole thing in the INDIRECT function. Instead of picking up the text string "$A$1:$A$53", it will actually now reference that range properly. Like so:
=INDIRECT(ADDRESS(ROW(A2),COLUMN(A2),1,1)&":"&ADDRESS(ROW(A2)+1+COUNT(A:A),COLUMN(A2),1,1))
USING A NAMED RANGE
But that is a very long formula to have, and you won't want to use it within a specific cell for a simple INDEX/MATCH. Instead of entering these formulas in cells (although you could), I recommend you go to the Formula Ribbon -> Name Manager -> New Name. Call the name for the index of A "ID_COLUMN". Call the name for the index of "B_COLUMN" (or something more specific).
FINAL FORMULA
Now, if you wanted to make an INDEX/MATCH of your table, which automatically grows/shrinks as you change the data, your formula would look like this [this would, for example, pick the row from column B where column A has the number 100]:
=INDEX(ID_COLUMN,MATCH(100, B_COLUMN, 0))

Import cell id to a formula

I have to calculate the standard deviation up to a particular cell in Excel. The value of the first cell is known to me. I also have found the cell id of the second cell, up to which I require the standard deviation, using the ADDRESS function and saved it in another cell.
How can I import that cell id into the formula for standard deviation?
This the formula I have already tried:
=STDEVP(C2:(INDEX(C88,1,1)))
where INDEX(C88,1,1) is used to get last cell id that I stored in cell C88.
Please try:
=STDEV(INDIRECT("C2:"&C8))
Is the reason that you have to look for the "2nd" cell is that you have a table that can increase in size? If so, I suggest changing your range into a table. Excel makes this quite easy with "Format as Table" on the "Home" ribbon.
If you do this, your formula will look as pretty as this:
=STDEV.P(Table1[Column1])
In addition, it resizes by itself. There is no need for hocus pocus.
A table can have a "Totals" row and it allow you to pick the function to use (yes, that includes STDEV).

Can I make a structured reference absolute in excel 07?

I have a table "A" with 2 columns "Foo" and "Bar". I have a formula with the structured reference A[Foo]. When I fill this formula horizontally I want the reference to stay A[Foo] but now, in the second column, the reference turns to A[Bar]. Is there a way to make this structured reference absolute?
It'd be shocking that this isn't supported if not.
Example Formula:
=A[Foo]
Drag that horizontally and Foo changes if the table has multiple columns
You can make the reference absolute by duplicating the reference to column as if it were a range. Looks like the following:
A[[Foo]:[Foo]]
Put A[[Foo]:[Foo]] in your formula and drag across. The reference will remain on the [Foo] column. Note, you have to drag the formula. Copy/paste won't work.
This also works if you want an absolute reference on a cell in the same row of the same table. Assuming the formula is in the Table named "A", the following will anchor the cell in the same row of the formula.
A[#[Foo]:[Foo]]
There is an article and video on my site about this issue where I attempt to explain it clearly. :)
http://www.excelcampus.com/tips/absolute-formula-references-excel-structured-table/
there is a difference between copying and dragging. Dragging is also called "filling" formulas. On Microsoft's support website you will find the following explanation:
Moving, copying, and filling
structured references
All structured references remain the
same when you copy or move a formula
that uses a structured reference.
When you fill a formula, fully
qualified structured references can
adjust the column specifiers like a
series as summarized in the following
table.
So it basically means that the behavior you see is by design. If you want the reference to be absolute you should copy the formula and not drag/"fill" it.
I couldn't make the Control+drag idea work either. However, by selecting the original cell and the ones to be filled and using the Control+R, fill right, shortcut did seem to copy without changing the structured references across columns.
It appears you cannot make a structured reference (.ie - A[Foo]) absolute. If you want to use absolute references in your formula, so you can use the fill handle, use the old method of absolute reference ($A$2 or $A2)
Example:
Table Name: DiscountPricing
A B C D
1 Item Base Price 5% 10%
2 Pencil $0.50 =[Base Price]-([Base Price]* =[5%]-([5%]*
DiscountPricing[[#Headers],[5%]]) *DiscountPricing[[#Headers],[10%]])
3 Pen $1 =$B3-($B3* =$B3-($B3*
*DiscountPricing[[#Headers],[5%]]) *DiscountPricing[[#Headers],[10%]])
See for additional info:
http://www.technicalcommunicationcenter.com/2011/05/31/how-to-use-structured-references-in-ms-excel/
Try inserting the Table name with an INDIRECT function like;
INDIRECT("Table Name[Column Heading]")
In your Case, INDIRECT("A[Foo]")
Now you can drag it horizontally and the column reference stays static !!
It seems that if you hold down Ctrl while copying the formulas, it will remain static/absolute.
http://office.microsoft.com/en-us/excel/HA101556861033.aspx
sounds like your still dragging/filling, aim for the bottom of the cell, not the corner.
Ross

Resources