EXCEL 2010, vertical search, parse cell - search

I need help with vertical search in Excel 2010.
I have a document with two sheets, in each sheet is one table containing data ...
sheet one
A B C D
123 sth sth 'need to find and copy value from second sheet(key is collumn A); formula here
321
678
845
983
sheet two
A B C
123, 321 sth 100 'looking for this value, copy 100 to first sheet to key 123 and also 321
678 99 'value for key 678 in sheet one
845, 983 82 'value for keys 845 and 983 in sheet one ..
I use vlookup(), but when I have two values separated with comma in one cell it doesn't work and I have to do it manually.
Is there a function something like vlookup which I can combine with left() and right() functions, or do I have to use something more sophisticated, a VB macro?
I cannot change layouts of these sheets ...
Thank you.

Use an array formula with SEARCH?
{=IF(SEARCH(A1,Sheet1!A:A),Sheet2!D:D)}
slightly more comprehensive version of that:
{=SUM(IF( NOT(ISERROR(SEARCH(A1,Sheet2!A:A))),Sheet2!D:D))}
as mentioned by Nanashi, you can change sum to average or whatever you like handle multiple values
You need to use ctrl+shift+enter to make a formula an array formula.

Rather hacky solution that uses formulas only.
Enter in Sheet1!C1:
=IF(COUNTIF(Sheet2!$A:$A,Sheet1!$A1)=1,VLOOKUP(Sheet1!$A1,Sheet2!$A:$C,3,FALSE),SUMIF(Sheet2!$A:$A,"*"&Sheet1!$A1&"*",Sheet2!$C:$C))
Sample result:
Sheet2
Sheet1
Disclaimer:
This method is very easy to break. One possible failing is that if there are no spaces between the IDs in Sheet2, the formula fails. Also, if by any chance the ID repeats in Sheet2, they will be added due to the usage of SUMIF. A workaround is to use AVERAGEIF instead.

Related

Excel function to sum all actual costs plus estimates on blank rows with no calculation column

In Excel 2013, I need to sum all numbers in a column of actual costs plus estimates in a second column in rows where the actual costs are blank.
Estimate (A) Actual (B)
Row 1 106
Row 2 212 230
Row 3 318 295
Row 4 424
totals 1060 525
I need to return 106 + 230 + 295 + 424. (or 525 + 106 + 424)
What I have tried:
--I have solved the problem if I put a placeholder (like "missing") in the blanks and then using a SUMIF nested in a simple SUM. But that badly clutters the chart.
=SUM(A5, SUMIF(B1:B4,"missing",A1:A4))
--I have also solved the problem by creating a calculation column that has an ISBLANK function and then using the SUMIF over that result. However, I can't figure out how to consolidate. I realize I could create another sheet to hold the calculation column, but the workbook will already have a number of sheets and I want to avoid an extra.
C1=ISBLANK(B1) dragged down to C4 and then =SUM(A5, SUMIF(C1:C4, "TRUE", A1:A4))
--I have found a number of online descriptions of managing similar tasks with pivot tables and months, but I can't seem to figure it out for a simple table.
I think my ISBLANK attempt is failing on consolidation because of something to do with absolute references vs. ranges in the column, but I can't figure it out.
Any advice would be greatly appreciated--thanks
Use SUMIF() to sum all numbers in column A if the value to the right is blank. Then add the sum of column B.
See this formula:
=SUMIF(B:B, "", A:A) + SUM(B:B)
Use array version of SUM(IF()):
=SUM(IF(B1:B4<>"",B1:B4,A1:A4))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

Unseen space (Char) in Excel Sheet causes 0 (N/A) as result, how to remove it?

I have two Excel sheet and I am using VLOOKUP to find a value from one of the excel sheets and insert it as new column in the second sheet. However when I try following formula I get 0 for all the rows:
=IFERROR(VLOOKUP(A1,Sheet2!A:B,2,FALSE),0)
So I did some research and tried every suggestion I found online but non of them worked.
Then I thought maybe the format of the sheets aren't the same so I did use format printer but still not working. everything looks similar in the common column of both sheets except one thing.
my common column (lets call it A) in one sheet has right alignment and in the other sheet has left alignment, even after doing Format Printer it's still not changing. So, out of curiosity, I did a backspace in one cell of sheet 2 and it worked(A=456). but there is no space in the cell.
So there is an unseen space, I tried Trim and Clean function, non of them worked.
So I'm not sure how to fix it. Any suggestion?
Sheet1:
A B
123 3/7/2016
456 6/9/2015
789 3/1/2016
sheet2:(Note: i did backspace for 456, it has right alignment now and it's working)
A B
123 4/8/2016
456 8/9/2016
789 3/7/2016
result after above formula:
A B C
123 3/7/2016 0
456 6/9/2015 8/9/2016
789 3/1/2016 0
Thank you
Sheet2 Column B is already formatted as date no need for DATEVALUE Function
Try =IFERROR(VLOOKUP(A1, Sheet2!A:B, 2, FALSE), "0")
The DATEVALUE Function is helpful in cases where a worksheet contains dates in a text format that you want to filter, sort, or format as dates, or use in date calculations.
To view a date serial number as a date, you must apply a date format to the cell. Find links to more information about displaying numbers as dates in the See Also section.
IFERROR Function Returns a value you specify if a formula evaluates to an error; otherwise, returns the result of the formula. Use the IFERROR function to trap and handle errors in a formula.

Subtracting columns in a Vlookup

I have a Excel spreadsheet that has two tabs, I have data on the DATA tab and the results of the data on the RESULTS tab. On the RESULTS tab I need to create a vlookup that will look for data on the DATA tab and subtract Column A from Column B. Is this possible with vlookup?
I have a before and after with the same clientID but data being copied/pasted will change.
Before
A B C
1021 102 125.00
1022 102 150.00
1023 105 100.00
After
A B C
1021 102 125.00
1022 102
1023 105 100.00
So each day I take the AFTER number and paste them over the before number, and get my new AFTER numbers from another tab.But if the pasted AFTER number does not have data for that specific account (in this case 1022), and the new AFTER number I get from another tab does not have data for 1022, my comparision will be off an account and will not notify me that this account is missing. I'm sorry, i know that is probably confusing.
I don't actually get why you need to use VLOOKUP to substract two columns...
In the results tab, you could just type
=IF(AND(DATA!B1<>"",DATA!A1<>""),DATA!B1-DATA!A1,"")
And copy the formula down the whole column.
The IF condition checks if both DATA!B1 and DATA!A1 are not empty, in which case it means they both have data and it will substract it. If one of the two columns is empty, it won't do anything, which is what you want.
If I didn't understand your question correctly, feel free to comment and clarify and I will propose something else.
Edit for VLOOKUP solution: I'm assuming that the client IDs are in column A in both tabs and you have to substract B from C in the same row as the ID in the DATA tab.
In RESULTS, use the following formula (put this one in row number 1 and copy it down):
=VLOOKUP(A1,DATA!A:C,3,FALSE)-VLOOKUP(A1,DATA!A:C,2,FALSE)
This will return 0 if both fields are empty, C if only B is empty and -B if only C is empty.
I can modify this if you need a different behavior depending on which columns are empty.
Hope this helps!
Yes it is possible with Vloopup.
=VLOOKUP(ResultsRefID,DATAarray,col1,FALSE)-VLOOKUP(ResultsRefID,DATAarray,col2,FALSE)
you could use that formula where ResultsRefID is the unique row identifier you are trying to get data for, DATAarray is all of the data in the DATA worksheet, and col1/col2 are the columns of data you want to have subtracted.
You can get the same results a little easier (I think) with an IF statement as an array.
=IF(ResultsRefID=DATAarrayUniqueIDrow1:DATAarrayUniqueIDrow1lastRow,col1FirstRow:col1LastRow-col2Firstrow:col2LastRow,"match not found.")
The IF statement has to be entered as an array (ctrl+shift+return)

Excel: check all columns have a different value

I would like to know how to compare for every row that their (numeric) columns have different values or all of them are equal, and get the result (either a boolean or a 0/1) in another column. Something like:
colA colB colC Result
row1 12 12 45 false
row2 67 67 67 true
How could I write this formula concisely in Microsoft Excel? Note that the number of columns may vary and at least I have about 30 columns, so I don't want to name the columns in the formula, but write something like a for
Thank you.
If you want to test only numbers, what about?
=MIN(B1:B30)=MAX(B1:B30)
(if your range goes from 1 to 30)
for doesn't exist in Excel formula, the best way to deal with a for loop would be to use array formulas but this is not appropriated here.
what you may look for is a dynamic range but i can't see a way to implement it easily in your case
[EDIT] new formula thanks to Excelll's comment
=AND(MIN(B1:B30)=MAX(B1:B30),COUNTBLANK(B1:B30)=0)
If blank cells within a row are not an issue, #JMax offers a clever solution. However, if you want a blank cell to return "FALSE", you can use the following array formula:
=AND(EXACT(A1,B1:C1))
Enter this as an array formula by pressing Ctrl+Shift+Enter.

Excel - Recursive VLookup

I recently came to know about Ctrl+Shift+Enter array formulas of Excel and currently still learning them. Coming to my problem,
SheetA:
Product Code
S1 19875
S2 19834
S1 13575
S1 35675
S2 47875
SheetB:
Code Indent
19875 40
19834 15
13575 22
35675 25
47875 20
I need to do Sum of all Indents of a given Product name.
Eg: I need S1's Total Indent,
Vlookup on SheetA, Get the Code 19875
Perform a vlookup on SheetB, Get the Indent of 40
Next Vlookup on Sheet A, Get the code 13575
Use 13575 to Vlookup on SheetB, Get Indent of 22
Next Vlookup on Sheet A, Get the code 35675
Use 35675 to Vlookup on SheetB, get indent of 25
Sum of 40+22+25, Return 87
I can achieve this through VBA, but I'm wondering if this is possible within excel functions using CSE/Array formulas.
Edit:
I don't have values in Sheet2 in the same order of Sheet1.. They are completely random. My SheetB will be something randomly like following:
SheetB:
Code Indent
19834 40
19875 15
47875 22
13575 25
35675 20
{=SUM(NOT(ISNA(MATCH((($A$2:$A$6="S1")*(B2:B6)),Sheet2!$A$2:$A$6,FALSE)))*(Sheet2!$B$2:$B$6))}
The first argument of the MATCH resolves to
{19875;0;13575;35675;0}
The MATCH resolves to
{1;#N/A;3;4;#N/A}
You'll have to make sure you don't have zeros in SheetB. The NOT ISNA turns those into TRUEs and FALSEs and resolves to
{TRUE;FALSE;TRUE;TRUE;FALSE}
And the final SUM looks like this
=SUM({TRUE;FALSE;TRUE;TRUE;FALSE}*{40;15;22;25;20})
Update
I can't figure out a single-array solution when the lists are in a different order. My attempts with OFFSET and TRANSPOSE either gave the wrong answer or crashed Excel. If you can stand using a helper column, you could put this formula in third column of your first sheet
=VLOOKUP(B2,Sheet2!$A$2:$B$6,2,FALSE)
and then use this array formula to sum them up
{=SUM(($A$2:$A$6=A2)*($C$2:$C$6))}
If the Code column were identical (same order) on both SheetA and SheetB, a simple SUMIF function would do. Similarly, if the INDENT data were on SheetA, you could also use a pivot table to calculate the sums quickly.
I'm guessing the design of your workbook won't allow this though. In which case, I don't have any easy solutions, but I'll give it another look.
You could use the below:
//Ola.S
Table 1
Col:A B C
Product Code Intendent
Col C: =SUMIF($E$4:$E$8;B4;$F$4:$F$8)
Table 2
Col:E F
Code Intendent
Table 3
Pivottable (Col:A and C)
On sheetC
If A1 has S1 then in Cell B1 type
=SUM((IF((Product=A1),Code1)=TRANSPOSE(Code2))*TRANSPOSE(Amt))
Array entered
Where
Code1 = Dynamic Range for Codes on SheetA starting from Row2
Code2 = Dynamic Range for Codes on SheetB starting from Row2
No TRANSPOSE calls needed.
Try the array formula
=SUM(SUMIF(SheetB!A2:A6,IF(SheetA!A2:A6="S1",SheetA!B2:B6),SheetB!B2:B6))
Assuming no cell in SheetB!A2:A6 it evaluates to FALSE. If the Code columns were all numeric (probably a questionable assumption), this could be done without an array entry using:
=SUMPRODUCT(SUMIF(SheetB!A2:A6,SheetA!B2:B6/(SheetA!A2:A6="S1"),SheetB!B2:B6))
Assuming no cell in SheetB!A2:A6 evaluates to #DIV/0!.

Resources