I have an excel sheet with few columns. One of the columns is a drop down based on a handful of values that I added. However, For each drop down value there is a matching account number which I would like auto populated once the drop down value is selected. Column D has the drop down and the drop down values and accounts are in BR5: BS38 and Would like the account to be populated in column E automatically everytime a drop down values is chosen.
Code I am using, however, it doesnt populate automatically, I have to copy the formula down and when I copy it down, if nothing is chosen in the drop down it will se #N/A.
=VLOOKUP(D5:D38,$BR$3:$BS$38,2,0)
Without VBA the formula will have to be copied down.
An easy work around would be to nest your vlookup in an iferror function and have it already populated in a set range of rows. So if you know the user will never type more than 1000 rows have the formula already there.
Your new formula would look like this. The only thing this does is remove the #N/A. Not sure why you specified a range in your vloopup lookup value, so this formula only picks the first cell in that range.
=IFERROR(VLOOKUP(D5,$BR$3:$BS$38,2,0), "")
If you would like some error checking, not sure if your drop down allows foreign values, you can use a formula like this
=IF(D5="","",IFERROR(VLOOKUP(D5,$BR$3:$BS$38,2,0),"Not Found"))
Related
I have a table in excel which is constantly having new rows added. I then have another sheet (lets call it results) which is referencing this table, and counting the values in each column.
Every time I add a new record/row to my table, the results sheet throws a bunch of errors in every cell that references the column. Because I'm using a fixed range in the formula to count the column, e.g. =SUM(A1:A10), I then need to manually click each cell in results and select 'include adjacent cells' to get the count to reflect the new data. I have loads of cells in this table and I'm adding data daily so this is a very long winded way of doing things.
I'm looking for a way that I can automatically update these cells, either by using a macro, or adjusting the formula so that it will automatically increase the range of the SUM when I add new data.
The best solution I've had so far was to simply define the range to include the row below my last piece of data (i.e. if A10 is my last record, the formula would be =SUM(A1:A11)). This works, and auto increments the formula when a new cell is added. However, if I delete the record from the table for any reason, the formula reverts to only including the range containing data.
In other words, this solution works, but only until I have to delete a record. Is there any better solution that can detect which rows are populated, and auto include them in the formula?
=SUMPRODUCT(INDEX('Sheet1!'A:A,1):INDEX('Sheet1!'A:A,LOOKUP(2,1/('Sheet1!'A:A<>""),ROW('Sheet1!'A:A))))
Using INDEX and ROW reference, deleting cells won't result in broken cell references. LOOKUP is used to calculate the last non-empty cell in column A. This will auto update.
Using SUMPRODUCT instead of SUM makes it an array formula and does not require older Excel versions to enter the formula with ctrl+shift+enter (because of the LOOKUP function)
In Office 365 you could use: =SUM(FILTER('Sheet1!'A:A,'Sheet1!'A:A<>""))
I have a list with a column that did a lookup to another sheet in the workbook. The original formula looked like this: =VLOOKUP([#[Last Name]]&" "&[#[First Initial]],LookupLastF,9,FALSE).
Later the lookup column was moved, so I had to change the formula to lookup column 10 instead of 9: =VLOOKUP([#[Last Name]]&" "&[#[First Initial]],LookupLastF,10,FALSE). I had to manually copy the formula through the column, because there were exceptions -- i.e. some items overwrote the formula with manually entered values.
The problem is every time a new row is inserted into the table, the old formula is copied to the row instead of the corrected formula. So a default based on the original formula must still exist somewhere. How do I change it to the new formula?
You have to delete the content of the whole column and then (re-)apply the formula.
Mixing formula and static values within one column isn't a good idea.
Use three columns instead: calculated value, manual value, result value (where a formula shows the manual value if exists and if not the calculated value)
How to create a drop down list to select values that with a specific input.
For example, if I have a table below.
And then, I would like to have a drop down list to select dates by the name. Like the one below.
I feel like it can be done by using array formula and if function, something like IF(A2:A7=A,B2:B7). It seems array formula cannot be used in a drop down list.
Thanks!
Few steps involved but not to hard:
Sorted column A
Create new named range, e.g.: DropList`
=INDEX(Sheet1!$B:$B,MATCH(Sheet1!$D$2,Sheet1!$A:$A,0)):INDEX(Sheet1!$B:$B,MATCH(Sheet1!$D$2,Sheet1!$A:$A;0)+COUNTIF(Sheet1!$A:$A,Sheet1!$D$2)-1)
Insert your dropdown validation list and reference the named range
=DropList
Unsorted column A
You'll need a helper column for this.
In cell H1 create a formula:
=IFERROR(AGGREGATE(15,3,($A$2:$A$7=$D$2)*($B$2:$B$7),COUNTIF($A$2:$A$7,"<>"&$D$2)+ROW()),"")
Drag the formula down to H7
Go to name manager and create a new named range, e.g.: DropList
=Sheet1!$H$1:INDEX(Sheet1!$H:$H,COUNTA(Sheet1!$H:$H))
Insert your dropdown validation list and reference the named range
=DropList
Confirm
=INDIRECT(ADDRESS(MATCH(D2,A1:A7,0),2)&":"&ADDRESS(MATCH(D2,A1:A7,0)+COUNTIF(A1:A7,D2)-1,2))
This should work, assuming the data is sorted by name. ADDRESS(MATCH(D1,A1:A7,0)+1,2), add that to the number of rows used in heading, in this case 1, this should return the address of the first cell of the data, column '2' refers to the column in which data is and it should return "$B$2", then in the second part of the formula we calculate the number of 'A' in the data using COUNTIF and add it to the first cell of the variable, similar to the 1st formula we give column as 2.
Then we use Indirect function to convert the strings to address which the data validation can use. And i guess you already know how to use Lists in data validation.
Alternatively, you can keep the address part in one cell, either hide the column or colour text white and protect the cell, and the refer as indirect from the Lists in data validation.
The goal is to create a series of graphs that will update automatically based on the raw data.
So, I have created a graph manually and want to edit the formula to accomplish the auto update.
The column names will always be the same, so I want to be able to select all data in a column based on the name BUT ignore any cell that is blank (above zero maybe).
The formula excel has given me so far is
=SERIES(rawdata!$M$1:$M$6,rawdata!$A$2:$A$37,rawdata!$M$2:$M$37,1)
So, something like
=SERIES(rawdata![column name],rawdata![column name],rawdata![column name],1)
I'm not sure how the skipping blank columns should work either. To expand on this further only one of the columns can potentially contain blank values. So if a cell is blank in that column then that entire row shouldn't be plotted, if that makes sense!
strong text =OFFSET(Sheet1!$B$2,0,0,COUNTA(Sheet1!$B:$B) - 1)
Try this formula when you define the name for the column of values you would like to have data automatically added from. I know it works when each cell has either a formula or a value. Like a column that is automatically calculated based on values in other columns.
In this formula example the cell B2 refers to the first point of data in the column. (make sure your references are absolute! ie, use $B$2)
This automatically returns the range of data as it changes when CountA is added:
=OFFSET(reference, rows, cols, [height], [width])
=COUNTA(value1, [value2], ...)
Hope this helps! It worked for me! :) If you have completely blank cells in the column you might have to make a couple changes though.
-Reverus
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)