Copy cells if conditions met - excel - excel

With Excel I would like to copy all cells values if conditions met.
In a specific case, I would like copy all the values from column C to a new column G, but only if the year = 1980 and Cracked password = 1.
Thus, as shown in the example below:
Thanks for the help.
Greetings T.

You can run an if function along column G and then use CTRL + g to delete the blanks
Vinnie's Idea is easier

If you want a formula, put this in G2 and copy down:
=IFERROR(INDEX(C:C,AGGREGATE(15,6,ROW($B$2:$B$12)/(($B$2:$B$12=1980)*($D$2:$D$12=1)),ROW(1:1))),"")

you can use this formula
=IF(AND(A2=1980,C2=1),B2,"")

Related

Conditional Formatting using another cell

I have a spreadsheet and want to conditional format Column G based on if Column D contains the word "Sale".
I have tried the following:
Cell Value = "Sale"
I have also tried the formula:
=D2="Sale"
Any assistance would greatly be appreciated. I am using Excel 2013
Make sure your formula row reference aligns with your range the rule applies to:
If the rule applies to the entire column G, use
=$D1 = "Sale"
If the rule applies to a range starting with G2 for example, use
=$D2 = "Sale"
Well, put this together just to show something:

Match and concatenate formula?

I have two excel columns. I need to compare the two columns (A & B) for matches and append everything after the delimiter, like so:
Column A
123456;cc01
654321;cc02
333333;cc03
444444;cc04
555555;cc05
Column B
111111
222222
333333
444444
555555
The output should be the following due to three matches in this example:
Column C
333333;cc03
444444;cc04
555555;cc05
Thanks in advance for your help!
Try this array formula (line break added for readability):
= IFERROR(INDEX($A:$A,SMALL(IF(($B$2:$B$6-LEFT($A$2:$A$6,FIND(";",$A$2:$A$6)-1))=0,
ROW($A$2:$A$6)),ROW($A2)-MIN(ROW($A$2:$A$6))+1)),"")
Note this is an array formula, so you have to press Ctrl+Shift+Enter instead of just Enter after typing the formula.
See working example below. I have this formula in cell C2 and dragged down.
This formula also works if you insert rows with new data. See below.
Or this regular entered formula:
=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$1:$A$6)/(ISNUMBER(MATCH(--LEFT($A$1:$A$6,FIND(";",$A$1:$A$6 & ";")-1),B:B,0))),ROW(1:1))),"")
Put in the first cell and copy down.
to deal with ever enlargin data use this:
=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$1:INDEX(A:A,MATCH("zzz",A:A)))/(ISNUMBER(MATCH(--LEFT($A$1:INDEX(A:A,MATCH("zzz",A:A)),
FIND(";",$A$1:INDEX(A:A,MATCH("zzz",A:A)) & ";")-1),B:B,0))),ROW(1:1))),"")

Excel help - Rearranging Columns

So I need some help with excel.
What I have is in Black and what I need is in Red.
I have been able to rearrange column B to match column A and have it output in E but I need it to take the values in column C and D with it. This is what I have been using in column E:
=IF(ISNA(VLOOKUP(A1,$B:$B,1,FALSE)), "Missing", A1)
Can someone please help me figure out how to bring columns C and D with column B and populate them in F and G.
Any help is much appreciated! Thanks!!
You were pretty close - Since this is a dynamic range, I would suggest using the OFFSET() function from a specific location in your spreadsheet.
So, here's the formula you could paste into cell E1 and drag across / down to get the result you want:
=IFERROR(OFFSET($A$1,MATCH($A1,$B:$B,0)-1,COLUMN(A1)),"Missing")
Basically, what you're saying is:
If I get an error in matching the value I want, print Missing:
=IFERROR(MATCH($A1,$B:$B,0),"Missing")
Move a set number of rows from cell A1 based on where the numbers match with column A:
OFFSET($A$1,MATCH($A1,$B:$B,0)-1 ...
As I drag to the right, keep referencing the next column:
OFFSET($A$1,..., column(A1))
Hope that helps explain it.

Excel INDEX and MATCH Get Value

I have an excel workbook that I need some help with INDEX and MATCH or any other Formula that can get me my end result.
Here is sheet1:
SIT_ID METER SUSE_CD
10834282 DT0061 B
10834282 AW7931 P
21676286 CQ9635 P
21676286 DP4838 B
21726281 AW7880 P
21726281 DT0032 B
Here is Sheet2:
Site ID B P
10834282
21676286
21726281
Ultimately what I am trying to do is on Sheet2 is put the Meter that = B for the SITEID in the column and then Put the Meter that = P in the Same row.
I have never used Index or Match and I looked it up online but I am confused and hoping someone can help me with the correct formula or point me in the right direction.
Thanks so much!
INDEX first takes a range, then a row number, an optional column number (and an optional area number).
MATCH takes a value to lookup, an array and a mode.
In your problem you can use the following in Sheet2 cell B2:
=INDEX(Sheet1!$B$2:$B$7, MATCH($A2, IF(Sheet1!$C$2:$C$7=B$1,Sheet1!$A$2:$A$7), 0))
This formula is an array formula and will work with Ctrl+Shift+Enter and then you can fill it to the other cells.
I had to use an IF because there're two conditions to check.
EDIT: Use this one if your cell formats are different:
=INDEX(Sheet1!$B$2:$B$7,MATCH($A2*1,IF(Sheet1!$C$2:$C$7=B$1,Sheet1!$A$2:$A$7*1),0))
EDIT2: Adding trimming:
=INDEX(Sheet1!$B$2:$B$7,MATCH($A2*1,IF(TRIM(Sheet1!$C$2:$C$7)=TRIM(B$1),Sheet1!$A$2:$A$7*1),0))
EDIT3: If you're using it on your full data, change the range:
=INDEX(Sheet1!$B:$B,MATCH($A2*1,IF(TRIM(Sheet1!$C:$C)=TRIM(B$1),Sheet1!$A:$A*1),0))
Assuming your Sheet1 looks like this:
And your Sheet2 looks like this:
The formula in Sheet2 cell B2 and copied over and down to cell C4 is:
=INDEX(Sheet1!$B$2:$B$7,MATCH(1,INDEX((Sheet1!$A$2:$A$7=$A2)*(Sheet1!$C$2:$C$7=B$1),),0))
Note that this is a regular formula, so no need for Ctrl+Shift+Enter
A helper column D is added to initial columns.
D2: =$A2 & $C2
Now it's possible to make a simple search of the concatenated SITE_ID and SUSE_CD:
H2: =MATCH($G2&" B";$D$2:$D$8;0)
The result would be a row number (=1 in this case) for the needed string in array $D$2:$D$8.
INDEX shows the value of the cell, found by counting n-th row (defined by MATCH) and m-th column (=2) in array $A2:$A$8 from the upper left cell (A2).
Altogether: =INDEX($A$2:$B$8;MATCH($G2&" B";$D$2:$D$8;0);2)
The easiest way to get around with this is,
to use concatenation operator in the match function.
Don't forget to use Ctrl+Shift+Enter
Use below formula in column B of Sheet 2
{=INDEX(Sheet1!$B:$B,MATCH(Sheet2!$A2&Sheet2!$B$1,Sheet1!$A:$A&Sheet1!$C:$C,0))}
And the below formula in column C of Sheet 2
{=INDEX(Sheet1!$B:$B,MATCH(Sheet2!$A2&Sheet2!$C$1,Sheet1!$A:$A&Sheet1!$C:$C,0))}
And then flash fill the remaining rows.

Excel SUM and IF combine help

I have two columns of numbers. Both are 1 to 5. I want to count all the cells where the left column value equals the right column value AND the left column value equals a certain value.
I tried this:
=SUM(IF(W2:W13=X2:X13 AND W2:W13=4,1,0))
I've tried pressing Ctrl+Shift+Enter and it adds {} around the formula but that didn't help either.
I think it's the W2:W13 = 4 part that doesn't work
=COUNTIFS(W2:W13,"=4", X2:X13, "=4")
You can use the sumif() function:
SumIf( range, criteria, sum_range )
it will apply the criteria for each row in the range.
Edit: to count the matches, you can use sum_range = 1 or use the Countif() function suggested by Ben in his answer
Have you considered a third column (C) with the formula IF(A1=B1,1,0) and then summing that third column?
I'm not much of an Excel Expert, but didn't they craeted the COUNTIF(range, criteria) function for this?
Add a third column eg Z2:Z13 with this formula: IF(AND(W2=X2; W2=4); 1; 0)
Then sum that one.
I don't have Excel 2007. So here's how you can do it in Excel 2003:
=COUNT(IF((W2:W14=4)*(X2:X14=4),Y2:Y14))
Since you are looking for a specific value and the column next to it to be the same value, you can just compare both columns to the same value.
The trick to get this to work is after entering the formula you need to hit F2 to go into edit mode and then hit CTRL-SHIFT-ENTER which makes this formula an array formula. This will put {} around the entire formula. Without making this an array formula this formula won't work.
I found this information in the Excel help document titled Count how often a value occurs

Resources