how to get such results using excel formula - excel

i have two excel sheets
An example of the two sheets are below
sheet1
a 1
b 2
d 1
e 3
g 1
sheet2
a
b
c
d
e
f
i want to put a formula in b1 of sheet 2 and drag it down so that the resulting sheet 2 is
sheet2
a 1
b 2
c 0
d 1
e 3
f 0
explanation : - a = 1 because same value in book1
b = 2 because same value in book1
c = 0 because c does not exist in book1
d = 1 because same value in book1
e = 3 because same value in book1
f = 0 because f does not exist in book1
what formula can i use in b column of sheet 2 ?

A combination of if(), iserror() and vlookup() will be your best bet here.
Assuming your data from sheet1 is in a range called 'refdata',
=IF(ISERROR(VLOOKUP(A1,refdata,2,FALSE)),0,VLOOKUP(A1,refdata,2,FALSE))
should do what you need (Where A1 is the cell containing the data you want to match on)

In Excel 2007 it looks like this:
=IFERROR(VLOOKUP(A1,sheet1data,2,0),)

Related

Excel index ,if and And

I have two sheets in excel. Sheet1 has A, B, C and D columns. Sheet2: A, B, E as columns. I want compare Sheet1 and Sheet2 columns (A&B) and write C from Sheet1 only if A&B in both sheets matches.
Eg:
Sheet1
A B C D
Sheet2
A B E
Add column C in Sheet2 only if A&B columns in both sheets matches
You can use vlookup function.
In Sheet1 you need to make a new column consisting of a and b at the beginning, for example:
Sheet1:
A B C
1 2 a
2 3 b
4 6 c
Sheet1 after changes:
new_column_A old_A B C
12 1 2 a
23 2 3 b
46 4 6 c
New_column_A can be created using formula =old_A1&B1
If you have this in your Sheet1 you can use vlookup function in your Sheet2 in column C to look for the values from Sheet1.
Sheet2
A B C
2 3 b
1 3 #N/D!
4 6 c
5 8 #N/D!
Your formula for C column would look like that:
=VLOOKUP(A1&B1,Sheet1!$A$1:$D$4,4,0)
If you don't want the #N/D! values you need to add IF condition:
=IF(ISERROR(VLOOKUP(A1&B1,Sheet1!$A$1:$D$4,4,0))=TRUE,"",VLOOKUP(A1&B1,Sheet!$A$1:$D$4,4,0))
Result:
A B C
2 3 b
1 3
4 6 c
5 8

Is there a formula that inputs on nth row of column A by reading what's in column F and/or D on their congruent rows?

I'm very new to excel programming. Currently I'm working on an excel worksheet and I need a formula that inputs on nth row of column A by reading what's in column F and/or D on their congruent rows. So far I have something like:
=IF(AND(D:ROW(n)=0,F:ROW(n)="x"),A:ROW(n)="e",IF(D:ROW(n)=0,"N","X"))
e.g.
A B C D E F
1 e 0 x
2 N 0
3 X 2
Put this in A1:
=IF(D1 = 0,IF(F1="x","e","N"),"X")
And copy down.
The references are Relative, so as the formula is copy/dragged down they will change on their own.

SUM cell values based on multiple condition - either A column or B column cell is true. Any of the two. But not always both conditions are true

In my excel sheet I have 3 columns as :
A B C
===================
XYZ N 9
ABC N 1
MNO N 3
D 13
D D 7
D D 9
D 1
Now, From these sheet I want sum of all cells in C column where either value in A or B column's cell is 'D'.
something like : if(a='D' or b='D') then sum+=C
Here, for case SUM(where cell value is 'D' in columns A or B) will be 30.
Let's say you had those values in cells A1:C7, this should do the trick:
=SUMPRODUCT(C1:C7*(A1:A7="D"))+SUMPRODUCT(C1:C7*(B1:B7="D"))-SUMPRODUCT(C1:C7*(A1:A7="D")*(B1:B7="D"))
To explain the formula, it is:
(Sum of C where A = "D") + (Sum of C where B = "D") - (Sum of C where both A = "D" and B = "D")
The reason for the last part is to avoid double counting.

how to compare the charaters in excel

sheet 1 sheet 2 sheet 3 sheet 4
a a a a
b b b b
c c c c
a a b a
b b a b
c c a c
a b c b
My question is if all the three sheets contains the same letter then the sheet 4 should contain the same letter.
if sheet 1 and sheet 2 contains a and sheet 3 contains b then the result should be a in sheet 4.
if all the sheets has different letters then the result in sheet 4 should be b.
The Microsoft Excel EXACT function compares two strings and returns TRUE if both values are the same. Otherwise, it will return FALSE.
EXCEL EXACT SYNTAX
EXACT( text1, text2 )
=EXACT(A1, A2)
You can use a if-then-else statement in Excel, it looks like =IF(A=B,True,False); And you can nest one in another.
In sheet 4 (for the example cell A1) =IF(Sheet1!A1="a",IF(Sheet2!A1="a",IF(Sheet3!A1="a","a", "b"),"b"),"b")
This check is sheet1 is A, yes? check sheet 2 etc, else give B.
More about IF in excel: http://www.techonthenet.com/excel/formulas/if.php

Excel: find matching text against reference and paste corresponding values from reference

How can I perform a check for identical text between two worksheets. Then when I find a match I would like to paste a specific range of columns corresponding to a given text. For example:
worksheet 1
column N has values
e
e
a
b
e
c
d
worksheet 2
col A col B col C col D
a 0.1 0.1 0.1
b 0.3 0.5 0.3
c 0.3 0.1 0.4
d 0.3 0.2 0.5
e 0.5 0.6 0.9
This way Worksheet 2 is the reference. We want to filter Column N in Worksheet 1 against Worksheet 2 Column A. If we find a match we want to take the corresponding values from Columns B, C, D and put them into Worksheeet 1 after Column N (say Columns O, P, Q).
How could I do this with a formula or a VB macro?
Name A:D in Worksheet 2 (say array) and apply =VLOOKUP($N2,array,COLUMN()-13,FALSE) in O2 of Worksheet 1 (assuming the top e is in N2) and copy across and down as required.
U sing Formula Vlookup you can do it as follow :
assuming you have value in N column i,e. a,b,c,d etc. in sheet1 and refrence values in range of column A to E whiles A containing
refrence value i.e. a,b,c,c etc. in sheet 2
Enter the following code in Sheet 1 in mentinoed cell and drag it down
the rows in sheet 1
=VLOOKUP(N1,Sheet2!$A$1:$E$3,2,FALSE) in O1 cell
=VLOOKUP(N1,Sheet2!$A$1:$E$3,3,FALSE) in P1 Cell
=VLOOKUP(N1,Sheet2!$A$1:$E$3,4,FALSE) in Q1 cell
note: you will need to modify the range in Vlookup as per the length of you reference data currently it will cover only first three row $A$1:$E$3 and 4 column.

Resources