To merge two sheet into one - excel

I have a excel sheet in the following format:
Sheet A contains
FilePath | Value1
E:\xampp\htdocs\D1.php | 1
E:\xampp\htdocs\D2.php | 1
Sheet B contains
FilePath | Value2
E:\xampp\htdocs\D2.php | 2
Output sheet:
Sheet C must contains
FilePath | Value1 | Value2
E:\xampp\htdocs\D1.php | 1 | #NA
E:\xampp\htdocs\D2.php | 1 | 2
To solve this I thought to add a new column in sheet A named "Value2" and then used VLOOKUP(A1,'SheetB'!A:B,1,FALSE) for row1, VLOOKUP(A2,'SheetB'!A:B,1,FALSE) for row2 and so on, but the output "#N/A" for all rows despite the fact that SheetB contains data for D2.php.
How can I resolve this? Is this is happening because cell values are "Absolute path"? Is there any other method?
Please help!

The #N/A error means that the lookup value cannot be found. Double check that the values are indeed a perfect match. There may be trailing spaces, for example.
Also, if you want to return the value, then the third parameter should be 2, not 1, since you want the value in the second column of the lookup range.

Related

Excel IF/THEN/VLOOKUP Nested Formula

I have two tabs in an excel file. Sheet 1 and Sheet 2. I have been working on a nested IF/THEN/OR/AND formula in excel that needs to do the following:
In Sheet 1, I need to make sure that two columns - Name 1 and Name 2 - match. If they do not match, I need to make sure that Name 2 matches to a Name column in Sheet 2.
Formula must - If Name 1 and Name 2 in Sheet 1 match, then YES, else NO. If NO, then VLOOKUP Name from Sheet 2 and Match with Name 2 in Sheet 1. If there is a match then display YES, else NO.
So far I have two separate columns that check for this. The first uses an exact statement to match the two name columns in sheet 1. The second does a vlookup to see if the name appears in the second sheet. I need this in one cell formula if possible and I am not sure how to do so without splitting.
+----------+----------+--+--+----------+
| Sheet 1 | | | | Sheet 2 |
+----------+----------+--+--+----------+
| Column 1 | Column 2 | | | Column 1 |
| Name 1 | Name 2 | | | Name |
+----------+----------+--+--+----------+
You will need to adjust the formula below for your sheet names and ranges, but this is a formula that will check column A against column B and if not the same, will check column B against a vlookup table. It also lets you know if there was not a match found in the vlookup table instead of just giving the error code #N/A
=IF(A3=B3,"Columns Match",IFERROR(VLOOKUP(B3,Sheet2!A4:B14,2,FALSE),"No Match Found In Vlookup"))

Index only cells in a column from another sheet if another cell in same row has a value greater than 0

So I have an example below of what I'm wanting to do.
Basically I need to Index Column B from Sheet 1 into Sheet 2 BUT ONLY if the values in Column W in Sheet 1 are greater than 0. If it's not then I don't want it to be included in. The only column to Index is B starting from row 5 to say 100. Same for Column W.
I was trying to do it myself as I found This which is very similar as what I'm wanting to do but I couldn't figure it out.
Sheet 1
Row# Column B | Column(s)… | Column W
=================================
5) Thing 1 | | 0
6) Thing 2 | | 3
7) Thing 3 | | 0
8) Thing 4 | | 1
Sheet 2
Row# Column B | Column C | Column D
=================================
5) Thing 2 | 3 |
6) Thing 4 | 1 |
7) | |
8) | |
EDIT #3
You can use either SMALL, LARGE function to return the values from Column B on your Sheet1.
Presume you have given the following names:
Sheet1ColB: Sheet1!B5:B100
Sheet1ColW: Sheet1!W5:W100
Here is the formula to be put in Cell B5 on your Sheet2. Please note it is an array formula so you need to press Ctrl+Shift+Enter to confirm.
{=IFERROR(INDEX(Sheet1ColB,SMALL(IF((Sheet1ColW>0)*(LEN(Sheet1ColW)>0),ROW(Sheet1ColW)),ROW()-4)-4),"")}
or
{=IFERROR(INDEX(Sheet1ColB,LARGE(IF((Sheet1ColW>0)*(LEN(Sheet1ColW)>0),ROW(Sheet1ColW)),ROW()-4)-4),"")}
You can then use INDEX+MATCH to return the value from Column W on your Sheet1 in Column C on your Sheet2:
=IFERROR(INDEX(Sheet1ColW,MATCH(B5,Sheet1ColB,0)),"")
In the above screen-shot Solution 2 is using AGGREGATE which follows the same logic as SMALL/LARGE.
As you can see the sample data has taken into account duplicated values in Sheet 1 Col W, blank cells in both Column W and Column B on Sheet1, and blank cells, negative value or 0 value in Column B only on Sheet1.
Cheers :)
Use AGGREGATE() formula to filter based on condition.
=IFERROR(INDEX($A$5:$A$8,AGGREGATE(15,6,(ROW($A$5:$A$8)-ROW($A$4))/($B$5:$B$8>0),ROW(1:1))),"")

Increment count in column based on value in column

I've 2 columns A and B. A contains names and B contains the count of those names till that record as shown below.
-----------------------------------
| A | B |
-----------------------------------
1 | Fruits | 1 |
2 | Flowers | 1 |
3 | Fruits | 2 |
So, want to have a formula for this. Expecting an array formula. Even if an array formula is not possible, a general formula
Attached a spreadsheet so that it can be explained better.
https://docs.google.com/spreadsheets/d/1wlWqdFwgv90s50iP-bXXBHciyualohj610qFiSatcmQ/edit#gid=1997586177
You do not need an array formula, and I would avoid them when possible. You can accomplish your task with
=COUNTIF(A$1:A1,A1)
Where A1 if the first value in the column of values you want to count. The $ allows you to anchor the top of your COUNTIF range while leaving the bottom dynamic.
In a google spreadsheet you may want to try:
=ArrayFormula(iferror(SORT(ROW(A1:A),SORT(ROW(A1:A),A1:A,1),1)-MATCH(A1:A,SORT(A1:A),0)-ROW()+2))
Example sheet

Find two matching rows and display data from the thirt one (Excel)

So i have Two Sheets.
First sheet contains two columns
BRAND | LEFTOVER
The second sheet consists of two columns also.
BRAND | LEFTOVER (%)
So in case if the BRAND row value in the first Sheet will match the BRAND row value in the second i want to display the matching LEFTOVER (%) row value in the first sheet rows in the column LEFTOVER.
Kind of lost here.
Appreciate any ideas. Thanks.
In Sheet2:
. A | B
--------------------
1 BRAND | LEFTOVER %
2 X | Y
3 |
In Sheet1:
. A | B
--------------------
1 BRAND | LEFTOVER
2 X | =VLOOKUP(A2,Sheet2!A:B,2)
3 |
The VLookup function searches for its first parameter (in this case the value of Sheet1!A2) in the first column of the range denoted by the second parameter (in this case the leftmost column of the range containing columns A and B on Sheet2)
It then returns the value from that same row of the range that is to the right in the columns denoted by the third parameter (1 is the leftmost column where the matched value was). So in this case we use the number 2 because 1 means column A and 2 is column B (which explains why we used a two column wide range for the second parameter - it needed to encompass the column the result was in)
This isn't the only way to do this, but it is the easiest.
As Jerry stated VLOOKUP is the simplest way to do this.
HOWEVER if you have multiple/repeat instances (rows) in BRAND, VLOOKUP will only return the first record (row) that appears in your data.
If this is the case, you will need to add either a unique identifier column; and/or additional criteria to differentiate between the repeat instances.
As an example column A is used as a unique identifier to differentiate between the 2 'Nike' rows.
A B C
1 BRAND LEFTOVER
2 Nike 50
3 Adidas 25
4 Reebok 30
5 Nike 29
I feel that you can use vlookup to accomplish your goals.
Let me explain it in a bit detail.Suppose you have two sheets as:
A | B | A | B
--------------------- | -------------------
1 BRAND | LEFTOVER % | 1 BRAND | LEFTOVER
2 X | Y | 2 X | =Vlookup(A2,Sheet2!A:B,False)
3 | | 3 |
Sheet2 | Sheet1
After this you can drag this formula for the entire range. This will automatically make the formula correct for the below cells as well.
Also, if you need to populate any other fields from the Sheet2 then you can also use the vlookup as an array formula like: VLOOKUP(A2,Sheet2!A:B,{1,2,3,4},FALSE)
Enter this as an array formula using Crtl+Shift+Enter
Here {1,2,3,4} stands for the columns to be fetched.
If you want to know more about vlookup then read this article: http://www.exceltrick.com/formulas_macros/vlookup-in-excel

Excel: Concatenate/retrieve cells that are across a merged key cell

Assume a simple sheet like so:
-------------
| 1 | a | Need formula to return: "a,b,c"
| |-----|
| | b |
| |-----|
| | c |
-------------
| 2 | a | Need formula to return: "a,b"
| |-----|
| | b |
-------------
The first column is the merged key cells and the second column has an unknown number of rows with text values in each cell.
What I want is a means, such as VLOOKUP/HLOOKUP, to retrieve a list of the cells across the merged key cell.
Even if I want to use Macros, how do I retrieve the a-b-c cell range programmatically as a result of VLOOKUP on the "1"?
If that doesn't work, I'm fine with just a logical check on whether a letter exists in the list.
For example, given a key value, I want to be able to programmatically apply conditionals like:
- "Does 'a' exist at '1'? Yes."
- "Does 'c' exist at '2'? No."
EDIT:
Keep in mind that the above is an example; I do not necessarily know that there is only 'a', 'b', and 'c'; I do not know the number of rows in each set.
Thanks.
This will give you True/False, though you can nest it in an IF statement to get Yes/No.
=NOT(ISERROR(VLOOKUP("b",INDIRECT(ADDRESS(MATCH(1,A:A,0),2)&":"&ADDRESS(MATCH(2,A:A,0)-1,2)),1,0)))
The variables are "b" which is the letter to look for, the 1 in the first match statement which is the number to key off of, and then the 2 in the second match statement is just the 1 variable +1.
The formula first determines the range of cells in column 2 for the 1 variable, by determining where it starts, and then going to one less than where the next number ends. Of course this will only work if the numbers are consecutive and ordered. It then does a VLOOKUP on the range that was determined, which for your example would be $A$1:$A$3.

Resources