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

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.

Related

scan Excel column based on another column value

I want to check one entire column with value in another column and then assign a value in another column value to matching row cell.
Eg-
A B C D
1 10 X
2 3 Y
3 2 Z
4 11 K
What I want to do is take one value at a time from column A eg 1 and then scan through Column B if matches the Column A (value 1) then assign x to that row under D. eg if we check A3 ( value 2) with column B and found 2 is on B4 then D4 = Z. Like this I want to check all values in column in A against column B assign relevant vale from column C to Column D
How can I do this, can someone please help me.
Thanks.
Try:
= IFERROR(INDEX($C$2:$C$5,MATCH(A3,$B$2:$B$5,0)),"no match")
See below.
Try:
=IFERROR(VLOOKUP(A1,$B$1:$C$5,2,0),"")

Highlight cells based on the value of cells in another column

I have this problem as noted below:
Column A = Part number
Column B = Quantity
Column C = Part number
Column D = Quantity
Using conditional formatting, I would like to highlight if the combination of Part number and Quantity in Column A and B is different to the combination of Part number and Quantity in Column C and D.
Eg:
Col A Col B Col C Col D
1 1111 2 1112 5
2 1112 3 1111 2
3 1131 5 1112 5
4 1122 3 1131 2
To do this, I'd like to set up a couple of 'helper' columns (say E & F) by concatenating Column A & B, C & D.
So essentially, I'd like to take the information from the helper columns E & F, but use conditional formatting to highlight the cell in column B and D.
From the example above, cell B3 and D4 would be highlighted.
Is this possible, and if not, is there are simple alternative? (I don't mind using a macro if need be).
I would use COUNTIFS
For B1:B4
=COUNTIFS($C$1:$C$4,A1,$D$1:$D$4,"<>"&B1)
and for D1:D4
=COUNTIFS($A$1:$A$4,C1,$B$1:$B$4,"<>"&D1)
In case you even want to skip the helper columns, you could format A1 with =$A1&$B1<>$C1&$D1 and copy the format to any cells in you want to be highlighted (even to your helper columns).

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.

How to select certain rows in Excel that meet logical criteria of A & B

I have an excel sheet in CSV that has 8 columns A-H and thousands of rows with values 0 or 1 depending on truth value.
I'm looking for the Excel function in which I can select rows where column A and B are true so that I can check another columns probability given A&B. IE P((A&B)|D) (where | means given).
I'm really new to excel and having difficulties finding how to only select rows that meet this criteria.
The following formula entered in I1 will return a 1 if both A1 and B1 are true.
=IF(AND($A1=1,$B1=1),1,0)
Copy it down or autofill to identify all rows where A and B are true.
The $ sign before A and B make the column references absolute meaning if you drag the formula to the right, the references to columns A and B will remain.
Because Excel implicitly interprets 0 = FALSE and 1 (or any other number) = TRUE the formula could be shortened to:
=IF(AND($A1,$B1),1,0)
The probability of C being 1 given that A and B are 1 can be calculated by counting all rows where A, B and C are all 1 and dividing by the number of rows where both A and B are 1:
=COUNTIFS($A:$A,"1",$B:$B,"1",C:C,"1")/COUNTIFS($A:$A,"1",$B:$B,"1")
Again, references to A and B are absolute, while C is relative so you can drag right to get probabilities for columns D to H.
COUNTIFS only counts the rows where all of the criteria are met and allows you to specify up to 127 range/criteria pairs.
EDIT
You could also use:
=AVERAGEIFS(C:C,$A:$A,1,$B:$B,1)
to get the probability.

How to format rows to color group by like values in column 1

I have a worksheet that has information like this:
a
a
b
c
c
c
How do I format it so that all of the rows that have a value of a in the first column are one color, then all the rows that have a value of b in the first column are a different color, etc. ?
Edit not from OP to add clarification from comment:
Everything is already sorted alphabetically, and will stay that way, and I want multiple colors.
Create a helper column with a formula like this;
=MOD(IF(A3=A2,0,1)+B2,2)
In this example column A is the column of sorted values to be grouped by, and column B is the helper column. The formula is entered on row 3. Set the first row of the helper column to the value 0 and the others to the formula. This will result in alternating values in the helper column for each group, ie;
a 0
a 0
b 1
c 0
c 0
c 0
d 1
d 1
e 0
You can then set conditional formatting based on the column value. If the value is 1 then highlight the row; if it is 0 do not highlight it. Or use alternating colors or whatever. You can reference any of the articles on the web that describe how to conditional format the entire row based on the value in the column.
IF(A3=A2,0,1) compares the current row (3) and prior row (2) returning a 1 or 0.
MOD( [...] +B2,2) accomplishes the alternation between 0 and 1 when the grouping column value changes.
I think you need a helper column, say B seeded with 1 in row1, and =IF(A1=A2,B1,B1+1) in B2 and copied down to suit. Then formulae of the kind below should suit for conditional formatting:

Resources