Essentially, I'm trying to come up with a formula that only extracts data from rows where a condition in a separate column of the same row is met, the condition is a constant and I know the answer must be stupidly easy, but I can't figure it out.
Example, say you have array like so:
Name Surname Status
------ ------- ------
John Bon Green
Jane Dane Red
Alex Flex Yellow
Romeo Cameo Green
Boris Horis Green
Julius Dubious Yellow
Holy Macaroni Green
And you wanted to have a list of people on a separate worksheet only with people with green status, without any blank rows in between when you drag it.
If our data is in Sheet1, columns A through C, then in Sheet2 cell A1 we enter the criteria:
Green
Then in Sheet1 cell D2 we enter:
=IF(C2=Sheet2!$A$1,1+MAX($D$1:D1),"")
and copy down:
This "Helper" column "marks" the rows of interest.
Then back on Sheet2, in A2 enter:
=IFERROR(INDEX(Sheet1!A:A,MATCH(ROWS($1:1),Sheet1!D:D,0)),"")
and in B2 enter:
=IFERROR(INDEX(Sheet1!B:B,MATCH(ROWS($1:1),Sheet1!D:D,0)),"")
Copy these cells downwards:
I've managed to figure it out, took forever.
=IFERROR(INDEX(INDIRECT("A" & SUM(MATCH(1,COUNTIF(A505, $A$1:$A$463),0),1)):$A$463,MATCH(1,COUNTIF($B$509,INDIRECT("K" & SUM(MATCH(1,COUNTIF(A505, $A$1:$A$463),0),1)):$K$463),0),),"")
LEGEND:
A505 = Previous result (Formula written in A506), Variable cell.
A1:A463 = Names
K1:K463 = Colours
The starting row of an Array will start 1 row below the previous result due to 'INDIRECT' formula.
From here it finds matching result to 'GREEN' in "K" Column represented by B509 and pulls how many rows below the starting row, then it uses row number in "A" Column to find the result that has "GREEN" as its colour.
If there's an error, it leaves the Cell Blank.
Related
In sheet 2 I have a list of 2 character codes(country codes) in cell A2 and in cell B2 I have numeric values(postcodes). In sheet 1 I have a larger list of 2 character country codes codes in Cell A2 and postcodes in cell B2 and a city name in Cell C2.
I am trying to use an if function to check if the country code in sheet 2 cell A2 exists in Sheet 1 Cell A2, then if Yes, use a vlookup to pull the city name from sheet 1 corresponding with the postcode in sheet 1 cell B2.
Below returns a result but when checking the results some are incorrect (I think it is due to duplicate country codes.
=IF(ISERROR(MATCH(A2,'Sheet1'!A:A, 0)), "No Match", VLOOKUP(B2,'Sheet1'!B:C,2,FALSE))
Any help is much appreciated!
thanks,
Danny
I often find that breaking out each section of your formula into separate columns is a good way to debug.
I would put the ISERROR(MATCH(A2,'Sheet1'!A:A, 0) in one column and the VLOOKUP in the next column and then put an if statement in the third column to calculate the outcome. Then try and figure out which part isn't doing what you expect it to be doing.
I have a vague memory doing this a year back and want to repeat the function. I want to use B2 as a reference to my formula, where my formula is reading in values from another tab and can be expanded by dragging and dropping. My picture is trying to illustrate the issue,
The pink cells are not using the reference cell B2, heading Formula 1 show the formula in column B.
The blue cells is what I have now, column D is the results from the formula in column E (row by row). Here I have created the formula in cell D4 and then dragged it down to D6.
The green cell is what I want to achieve, note the discrepancy marked in red.
I want to be able to write the formula in cell D4 and then drag it down to D6. How can this be done without adding new columns.
Use this:
=INDIRECT("'" & $B$2 & "'!C" & ROW())
I added '' around the sheet name in case the sheet name in B2 contains spaces.
I don't have any VBA experience, and I know I've done this once before with VLOOKUP at an old job, but I don't have access to those spreadsheets anymore.
In Sheet 1, Column A I have Product Colors
Red
Blue
Green
Purple
In Sheet 2, I paste a report that Quickbooks creates
Column A lists product colors (dynamic)
Red
Green
Pink
Purple
And Column B indicates a corresponding numerical value
I'd like to enter code into Sheet 1, B1 that references Sheet 1, A1 and searches Sheet 2 (A:A) for that data, and then prints the numerical found value in the adjacent B cell.
So if Sheet 1, A3 says Green, the code in B3 looks at A3, attempts to find the same string in Sheet 2 (A:A) (which it does find, in Sheet 2 A2) and then prints the value found in Sheet 2 B2.
Can anyone help? I've tried searching the forums, but can't seem to find this exact question.
Not impressed by you searching but please try something like:
=VLOOKUP(A2,Sheet2!$A$2:$B$5,2,0)
in Sheet1 B2 copied down to suit.
I have two columns A , B
A:have text
B:have values
I need to add the first value of B in first cell of Column C then, the next cell of column C have the first text of A and so on
EX:
C1:1234
C2:what is your name
OK... you aren't exactly clear on your question, since you can't have 2 cells in column C. But I think what you want to do is write this formula in cell C2:
=B2 & " " & A2
That will put values from both columns A and B in the same cell, separated by a space. But it's unclear what you want since "the first text of A and son on" could be interpreted many ways.
Please try the above formula and if it does not meet your demands then think of how you can rephrase your question.
----Edit----
In C1 enter the value:
=B1
In C2 enter the value:
=A1
Highlight both C1 and C2, then drag down with the fill handle. That should do it.
How Can I Get First Cell Content ?
here is my sheet
A
1 Color
2 Red
3 Blue
4 Yellow
note : Color has filter
i want to make the cell B1 = first cell of column A - I try type in B1 =A2
but when i make filter (example i select blue) the cell B2 show nothing (i want B1 to show the filtered data on first column )
A Non-Volatile AND Non-Array entered option is to use a helper column:
In B2 Enter =SUBTOTAL(3,A2) and drag it down. This will mark every row with a 0 or a 1 depending on if it is visible or not.
Then in B1 you can simply enter:
=INDEX(A2:A4,MATCH(1,B2:B4,0))
The above will search the B column for the first 1 (stands for visible), and return the value of the cell in column A of that row.
In B1 enter the array formula:
=INDEX(A2:A100,MATCH(1,SUBTOTAL(3,OFFSET(A2:A100,ROW(A2:A100)-ROW($A$2),,1)),0))
Array formula must be entered with CNTRL-SHFT-ENTER rather than just the ENTER key