vlookup values from other sheets disappear when file closed - excel

I've got a group of registers that I created for our volunteers and youth club members. Each register spreadsheet is from Sept to July. More and more volunteers and young people are staying with us for longer so I have been trying to create a vlookup that takes the total hours they volunteered from the previous years and add it to the current year total. This chains about 3-4 previous years of registers together. ie, 2014-15 adds to 2015-16 total, 2015-16 adds to 2016-17 total, 2016-17 adds to 2017-18 total, etc. The vlookup works great when all the previous years registers are open, but once I close one I get a #n/a error. How can I prevent the error msg and keep my formula working without opening all the documents?

Have you tried to specify the complete workbook path in your vlookup formula?
I.e. something like this:
=VLOOKUP(B1,'C:\School Projects\University\[Assignment.xlsx]DataYear'!$A3:$D10,3,FALSE)
Where:
Assignment.xlsx - is the name of workbook
DataYear - is the name of the worksheet
EDIT:
Since you mention you have tables when you are using your VLOOKUP you should use the Index + Match, is way more flexible. [#Data] won't work and VLOOKUP works best only if the return column is next to the search column, i.e. Column 1 is search and Column 2 is return values.
Example of applying INDEX + MATCH in table:
If I have an table in Book2.xlsx
And my table is named table 15:
Let's assume I have another woorkbook (Book1.xlsx). I want to check how many Quantity the person Sally sold. (My formula should return: 2, Cell C3).
Then my formula should be in the other excel book (Book1.xlsx):
=INDEX('G:\Folder Stuff\Book2.xlsx'!Table15[Qty],MATCH(B2,'G:\Folder Stuff\Book2.xlsx'!Table15[People],0))
So to apply for tables you should use:
Table15[Qty] - Return quantity, which refer to my column Qty in my example
Table15[People] - column to lookup my search value (sally), which refer to my column People in my example
Logic of INDEX + MATCH:
=INDEX(Column where result should be return,MATCH(lookup_value, Column where lookup value exist, Exact or Approximate Match)
So your formula should be something like this:
=INDEX('C:\Users\COG Youth Services\Dropbox...\Registers\Volunteers attendance record 2017-18.xlsx'!Table14[Name of the table column in Column 37],MATCH(StudentLookup,'C:\Users\COG Youth Services\Dropbox...\Registers\Volunteers attendance record 2017-18.xlsx'!Table14[Name of the table Column where StudentLookup exist],0))

Related

SumIF Using Table/Named Range Instead of Single Cell Criteria

I have 2 sheets in a workbook (Sheet1, Sheet2).
Sheet 2 contains a table (Named Table1) with 5 columns:
Takeaways
Household
Clothing
Fuel
Groceries
On sheet one, I have 2 columns:
Expense Name
Expense Total
Now, what I am trying to do is:
Set the range for the Expense Name (Range 1)
Set the range for the Expense Total (Range 2)
Compare Range 1 with the respective column in the table and only add up the values for matches
For example, in Range 1 (B6:B16):
BP
Caltex
McDonalds
KFC
In Range 2 (C6:C16):
300
400
200
150
Now, all I want to do is add up the values for the Takeaways (McDonalds, KFC) and exclude anything that DOES NOT match the criteria.
So my sum total will be all occurrences of Takeaways - provided they are listed in my table - 350 in this case.
But I cannot seem to get the formula to work.
I used these sources:
https://exceljet.net/excel-functions/excel-sumifs-function
Selecting a Specific Column of a Named Range for the SUMIF Function
and ended up with this formula:
=SUMIF($B$6:$B$16;Table1[Takeaways];C6:C16)
This source:
https://excelchamps.com/blog/sumif-sumifs-or-logic/
and ended up with this formula:
=SUM(SUMIFS(C6:C16;B6:B16;Table1[Takeaways]))
Both formulae return 0.
BUT, with BOTH of them, if I change Table1[Takeaways] to "McDonalds", then it correctly identifies every occurrence of the word "McDonalds" in Range 1.
EDIT:
I have updated the formulae above to match the images below.
This is the table that contains the references:
This table contains the data:
Formula:
Cell C4 (Next to Takeaways): =SUMIF($B$6:B$16;Table1[Takeaways];C6:C16)
Cell C5 (Next to Fuel): =SUM(SUMIFS(C6:C16;B6:B16;Table1[Fuel]))
It appears that ONLY BP is being detected in the formula.
This is a an output table when I use the formulae with a single cell reference and not a table or used range:
Formula:
Cell F4 (Next to BP): =SUMIF($B$6:B$16;"BP";C6:C16)
Cell F5 (Next to Caltex): =SUM(SUMIFS(C6:C16;B6:B16;"Caltex"))
Cell F6 (Next to McDonalds): =SUMIF($B$6:B$16;"McDonalds";C6:C16)
Cell F7 (Next to KFC): =SUM(SUMIFS(C6:C16;B6:B16;"KFC"))
If I understand correctly what you're trying to achieve, I think your setup is not right conceptually.
It looks like you're trying to track expenses, and each expense (or payee) is allocated to a category ("Takeaways", "Household" etc.). From a relational-model point of view, your second table (which defines the category for each expense/payee) should only have two columns (or variables): Expense Name and Expense Category.
The table you set up ('Sheet 2') uses the categories (i.e., possible values) as different columns (i.e., variables). But there's only variable, namely the "Expense Category", and the categories themselves are the possible values.
If you set it up like that, the problem changes: you can add a dependent column to your first table that shows the category for each payee (or "Expense Name"), using a VLOOKUP() from the second table.
You can then sum the expenses for all payees matching that category.
Note: I've created the illustration using LibreOffice Calc, so there might be some small differences, but the logic is the same.
Without seeing the data in L and K I can't give you a full answer - but likely it's to do with the way you're pulling your Array
Try something similar to this
=SUMPRODUCT(SUMIFS($L$11:$L$43,$K$11:$K$43,CHOOSE({1,2},Takeaways,"anything else you wanted to sum")))
Remember SUMIFS is for multiple criteria, so if you're only calculating one, you'll need =SUMPRODUCT(SUMIF(
The way the above works is with vertical vectors only, but changing your named ranges so the table of 2 columns is 2 named ranges instead should be okay - unless it's part of your requirements
Table 2 would become expense_Name and expense_Total etc
I was about to close this as a duplicate of my own question here but there is a bit of a difference in using a named range I think. However the logic behind this follows more or less the same approach.
Working further on my partial solution below I derived the following formula:
=SUMPRODUCT(COUNTIF(Table1[Takeaways];Range1)*Range2)
The COUNTIF() part counts the number of occurrences of the cell value in your table. Therefore make sure there are no duplicates in your table. If the value is present in the table the result of COUNTIF() will be 0. This way we create a matrix of 1's and 0's. By multiplying and the use of SUMPRODUCT() we force excel to perform matrix calculations and return the correct result.
Partial solution
I used the following formula:
=SUMPRODUCT(ISNUMBER(MATCH(Range1;Table1[Takeaways]))*Range2)
The formula does the following:
The MATCH()checks if the value in Range1 is present in your table and returns the position of the matching value in your table.
The ISNUMBER() checks if a match is found by checking if the MATCH() fucntion returned a number
Multiplying this with Range2 forces matrix calculation, using the SUMPRODUCT() function
EDIT:
This worked for a really limited sample. As soon as I added the fourth row to my data the formula stopped working as intended. See screenshot:
It took the first two values into the sum correctly, the fourth is not taken into account.

Count occurrences of certain number in worksheet column, looking up by header row

We keep track of salaries using an excel file with a tab per month:
50 = regular salary
100 = regular salary for double shift
30, 60 etc. are exceptions that don´t need to be considered
Now my boss wants to know who worked how often considering the normal and double shifts only. so the result should be a list(table) like Bob 50*X, 100*Y, Bill 50*X, 100*Y
What would the syntax look like? It´s possible that while Bill is B1 in January it might be that he is C1.. in another month so the solution should use the header row to do a lookup.
In your example, the formula
=COUNTIF(B2:B7,50)
will return the number of instances of the data 50 in the range B2:B7.
In order to find the column corresponding to a specific employee you can use MATCH, (e.g.) MATCH("Bob",B1:C1,0) which finds the exact text Bob in the range B1:C1. Now you need to change the range in your COUNTIF function to correspond to the column for Bob, which you can do with OFFSET:
=COUNTIF(OFFSET($A$2,0,MATCH("Bob",$B$1:$C$1,0),6,1),50)
The number 6 in the above formula is the number of rows containing salary data - could that change? If so you could replace it with e.g. MATCH("Tot",$B2:$A99,0)-1 which will count how many rows there are from row B to the row containing Tot.
Look up the functions COUNTIF, MATCH and OFFSET in the Excel help for more detail on how to use them.

Excel - Custom Lookup

I am having a really tough time finding a way to pull data from one sheet to another for a specific task.
On sheet1 I have 42005 (jan 1, 2015) in A1 and it goes to 42735 (Dec 31, 2016)
------A1------|42005|42006|42007|42008|...
Employee 1|-Yes--|-Yes--|-Yes--|-Yes-|...
Employee 1|-Yes--|-Yes--|-Yes--|-Yes-|...
I Need a "Yes", "No", or "Different Unique ID" to show up in the above list in the second row for conditional formatting from the data below. If the date in the header is listed in the bottom table, then i need a unique ID.
On sheet2 I have date ranges that employees work (45 days at work and 7 days off, for example)
Employee 1 | Employee 1 0.01| Employee 2 | Employee 2 0.01
Start--------- | End-----------------|Start-----------|End
42005------- | 42049---------------|42005---------|42049
45------------ | 10--------------------|45--------------|10
42060------- | 42104---------------|42060---------|42104
45 ----------- | 10--------------------|45--------------|10
42115------- | 42159---------------|42115---------|42159
45 ----------- | 10--------------------|45--------------|10
I need a way to match the current date to the start and end dates that are listed, they need unique ID as the result of an IF function for conditional formatting. This notes that it is either the beginning date or the end date which is considered a "travel day".
Basically, I need B2 in the top example to say IF an exact match of the above date in A2 can be found in column1 or column2 of employee 1's [section] in the table, then "unique ID". What I cant figure out is how to search in BOTH employee 1 and employee 1 0.01 columns depending on the name field in the top.
The name column in the top example is a list drop down, so i have to find a dynamic formula for this. Manually assigning a range to each cells lookup fields wouldn't work.
=HLOOKUP(B$2,Sheet2!$A$1:$GR$340,MATCH($A2,Sheet2!$A$1:$GR$1),FALSE)>=100,18, "false")
Clearly that doesn't work, but was an idea to try to get the search in the right area. No way i can find the correct column for the name, then select that column +340 rows, and +1 column to the right for the proper range, then look for specific value?
Is there a way to achieve this?
If I understand this correctly, you can solve this along these lines:
Find the column matching the employee name
Search the column to see if there is a match to the date value.
If there is no match, then search the next column to the right for a matching date value.
If there is no match in the second column, then return a value to indicate failure.
This formula is going to be really long and complicated so I'll break it up as best I can. You can start by finding the column matching the employee with a match function. This will return the column number.
=match(EmployeeName, EmployeeNames, 0)
Next, we'll want to search this column with a vlookup but you have to refer to the column by column number and not by letter. To do that, use indirect(address()). Address works by using the row number and column number to refer to a cell. We'll use one for the start of the column and one for the end of the column. Plug in the match formula from above and we have the range to search.
=vlookup(DateValue,indirect(Address(1,match(EmployeeName,EmployeeNames,0))):indirect(address(500,match(EmployeeName,EmployeeNames,0))),1,0)
Note that I used 500 as the end of last row of the column to be searched. You can make it more if needed.
So far this formula will return the date if the date is found in the first column matching the employee name and an error if there is no match. We still have to search the second column if there wasn't a match. I like to use the iferror() function for this. Put the formula above as the first argument of the iferror and also as the second. We'll modify the second to search the next column over. Since we are using the column numbers, we can just increment over by adding 1 to the column.
=iferror(vlookup(DateValue,indirect(Address(1,match(EmployeeName,EmployeeNames,0))):indirect(address(500,match(EmployeeName,EmployeeNames,0))),1,0), vlookup(DateValue,indirect(Address(1,match(EmployeeName,EmployeeNames,0)+1)):indirect(address(500,match(EmployeeName,EmployeeNames,0)+1)),1,0).
Almost there, now we have to handle the error if nothing is found in the second column as well. Wrap the second vlookup in an iferror and some constant at the end.
=iferror(vlookup(DateValue,indirect(Address(1,match(EmployeeName,EmployeeNames,0))):indirect(address(500,match(EmployeeName,EmployeeNames,0))),1,0),iferror( vlookup(DateValue,indirect(Address(1,match(EmployeeName,EmployeeNames,0)+1)):indirect(address(500,match(EmployeeName,EmployeeNames,0)+1)),1,0),"No Match").
When you set up the conditional formatting, you would set the formula to check if the cell value is (or is not) "No Match".

Excel: If Cell in Column = text value of X, then display text (in the same row, but different column) on another sheet

This is a confusing request.
I have an excel tab with a lot of data, for now I'll focus on 3 points of that data.
Team
Quarter
Task Name
In one tab I have a long list of this data displaying all the tasks for all the teams and what Quarter they will be on.
I WANT to load another tab, and take that data (from the original tab) and insert it into a non-list format. So I would have Quarters 1,2,3,4 as columns going across the screen, and Team Groups going down. I want each "task" that is labeled as Q1 to know to list in the Q1 section of that Teams "Block"
So something like this: "If Column A=TeamA,AND Quarter=Q1, then insert Task Name ... here."
Basically, if the formula = true, I want to print a list of those items within that team section of the excel document.
I'd like to be able to add/move things around at the data level, and have things automatically shift in the Display tab. I honestly have no idea where to start.
If there is never a possibility that there could be more that 1 task for a given team and quarter, then you can use a formula solution.
Given a data setup like this (in a sheet named 'Sheet1'):
And expected results like this (in a different sheet):
The formula in cell B2 and copied over and down is:
=IFERROR(INDEX(Sheet1!$C$2:$C$7,MATCH(1,INDEX((Sheet1!$A$2:$A$7=$A2)*(Sheet1!$B$2:$B$7=B$1),),0)),"")
I came across this situation. When I have to insert the values into a table from an Excel sheet I need all information in 1 Column instead of 2 multiple rows. In Excel my Data looks like:
ProductID----OrderID
9353510---- 1212259
9650934---- 1381676
9572474---- 1381677
9632365---- 1374217
9353182---- 1212260
9353182---- 1219361
9353182---- 1212815
9353513---- 1130308
9353320---- 1130288
9360957---- 1187479
9353077---- 1104558
9353077---- 1130926
9353124---- 1300853
I wanted single row for each product in shape of
(ProductID,'OrdersIDn1,OrderIDn2,.....')
For quick solution I fix it with a third column ColumnC to number the Sale of Product
=IF(A2<>A1,1,IF(A2=A1,C1+1,1))
and fourth Column D as a placeholder to concatenate with previous row value of same product:
=IF(A2=A1,D1+","&TEXT(B2,"########"),TEXT(B2,"########"))
Then Column E is the final column I required to hide/blank out duplicate row values and keep only the correct one:
=IF(A2<>A3,"("&A2&",'"&D2&"'),","")
Final Output required is only from Column E
ProductID Order Id Sno PlaceHolder Required Column
9353510 1212259 1 1212259 (9353510,'1212259'),
9650934 1381676 1 1381676 (9650934,'1381676'),
9572474 1381677 1 1381677 (9572474,'1381677'),
9632365 1374217 1 1374217 (9632365,'1374217'),
9353182 1212260 1 1212260
9353182 1219361 2 1212260,1219361
9353182 1212815 3 1212260,1219361,1212815 (9353182,'1212260,1219361,1212815'),
9353513 1130308 1 1130308 (9353513,'1130308'),
9353320 1130288 1 1130288 (9353320,'1130288'),
9360957 1187479 1 1187479 (9360957,'1187479'),
9353077 1104558 1 1104558
9353077 1130926 2 1104558,1130926 (9353077,'1104558,1130926')
You will notice that final values are only with the Maximum Number of ProductSno which I need to avoid duplication ..
In Your case Product could be Team and Order could be Quarter and Output could be
(Team,Q1,Q2,....),
Based on my understanding of your summary above, you want to put non-numerical data into a grid of teams and quarters.
The offset worksheet function will work well for this in conjunction with the match or vlookup functions. I have often done this task by doing the following steps.
In my data table, I have to concatenate the Team and quarter columns so I have a unique lookup value at the leftmost column of your table (Note: you can eventually hide this for ease of reading).
Note: You will want to name the input range for best formula management. Ideally use an Excel Table (2007 or greater) or create a dynamically named range with the offset and CountA functions working together (http://tinyurl.com/yfhfsal)
First, VLOOKUP arguments are VLOOKUP(Lookup_Value,Table_Array,Col_Index_num,[Range Lookup]) See http://tinyurl.com/22t64x7
In the first cell of your output area you would have a VLOOKUP formula that would look like this
=Vlookup(TeamName&Quarter,Input_List,Column#_Where_Tasks_Are,False)
The Lookup value should be referencing cells where you have the team names and quarter names listed down the sides and across the top. The input list is from the sheet you have the data stored. The number three represents the column number the tasks are listed in your source data, and the False tells the function it will only use an exact match in your putput.

In Excel 2007, how can I SUMIFS indices of multiple columns from a named range?

I am analysing library statistics relating to loans made by particular user categories. The loan data forms the named range LoansToApril2013. Excel 2007 is quite happy for me to use an index range as the sum range in a SUMIF:
=SUMIF(INDEX(LoansToApril2013,0,3),10,INDEX(LoansToApril2013,0,4):INDEX(LoansToApril2013,0,6))
Here 10 indicates a specific user category, and this sums loans made to that group from three columns. By "index range" I'm referring to the
INDEX(LoansToApril2013,0,4):INDEX(LoansToApril2013,0,6)
sum_range value.
However, if I switch to using a SUMIFS to add further criteria, Excel returns a #VALUE error if an index range is used. It will only accept a single index.
=SUMIFS(INDEX(LoansToApril2013,0,4),INDEX(LoansToApril2013,0,3),1,INDEX(LoansToApril2013,0,1),"PTFBL")
works fine
=SUMIFS(INDEX(LoansToApril2013,0,4):INDEX(LoansToApril2013,0,6),INDEX(LoansToApril2013,0,3),1,INDEX(LoansToApril2013,0,1),"PTFBL")
returns #value, and I'm not sure why.
Interestingly,
=SUMIFS(INDEX(LoansToApril2013,0,4):INDEX(LoansToApril2013,0,4),INDEX(LoansToApril2013,0,3),1,INDEX(LoansToApril2013,0,1),"PTFBL")
is also accepted and returns the same as the first one with a single index.
I haven't been able to find any documentation or comments relating to this. Does anyone know if there is an alternative structure that would allow SUMIFS to conditionally sum index values from three columns? I'd rather not use three separate formulae and add them together, though it's possible.
The sumifs formula is modelled after an array formula and comparisons in the sumifs need to be the same size, the last one mimics a single column in the LoansToApril2013 array column 4:4 is column 4.
The second to bottom one is 3 columns wide and the comparison columns are 1 column wide causing the error.
sumifs can't do that, but sumproduct can
Example:
X 1 1 1
Y 2 2 2
Z 3 3 3
starting in A1
the formula =SUMPRODUCT((A1:A3="X")*B1:D3) gives the answer 3, and altering the value X in the formula to Y or Z changes the returned value to the appropriate sum of the lines.
Note that this will not work if you have text in the area - it will return #VALUE!
If you can't avoid the text, then you need an array formula. Using the same example, the formula would be =SUM(IF(A1:A3="X",B1:D3)), and to enter it as an array formula, you need to use CTRL+SHIFT+ENTER to enter the formula - you should notice that excel puts { } around the formula. It treats any text as zero, so it will successfully add up the numbers it finds even if you have text in one of the boxes (e.g. change one of the 1's in the example to be blah and the total will be 2 - the formula will add the two remaining 1s in the line)
The two answers above and a bit of searching allowed me to find a formula that worked. I'll put it here for posterity, because questions with no final outcome are a pain for future readers.
=SUMPRODUCT( (INDEX(LoansToApril2013,0,3)=C4) * (INDEX(LoansToApril2013,0,1)="PTFBL") * INDEX(LoansToApril2013,0,4):INDEX(LoansToApril2013,0,6))
This totals up values in columns 4-6 of the LoansToApril2013 range, where the value in column 3 equals the value in C4 (a.k.a. "the cell to the left of this one with the formula") AND the value in column 1 is "PTFBL".
Despite appearances, it isn't multiplying anything by anything else. I found an explanation on this page, but basically the asterisks are adding criteria to the function. Note that criteria are enclosed in their own brackets, while the range isn't.
If you want to use names ranges you need to use INDIRECT for the Index commands.
I used that formula to check for conditions in two columns, and then SUM the results in a table which has 12 columns for the months (the column is chosen by a helper cell which is 1 to 12 [L4]).
So you can do if:
Dept (1 column name range [C6]) = Sales [D6];
Region (1 column name range [C3]) = USA [D3];
SUM figures in the 12 column monthly named range table [E7] for that 1 single month [L4] for those people/products/line item
Just copy the formula across your report page which has columns 1-12 for the months and you get a monthly summary report with 2 conditions.
=SUMPRODUCT( (INDEX(INDIRECT($C$6),0,1)=$D$6) * (INDEX(INDIRECT($C$3),0,1)=$D$3) * INDEX(INDIRECT($E7),0,L$4))

Resources