Formula to get cell values of specific column and a variable row number - excel

I need a formula to retrieve a value defined by a specific column (always B) and a variable row number (A).
What is the formula I need to write in column C to retrieve the right names as shown below?
_A_____B_______C_____
3 | Lucas | Gary <--B3
_____________________
1 | Mark | Lucas <--B1
_____________________
2 | Gary | Mark <--B2

You want to use the INDIRECT function.
Column C should be:
=INDIRECT("B" & $A1)
=INDIRECT("B" & $A2)
=INDIRECT("B" & $A3)
(you can just enter the formula in the first cell and copy it down)

Related

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))),"")

Using SUMIF on a range of columns or SUMPRODUCT to ignore text items

I have a range with various text and numbers in them. I wish to total the numbers based on the identifying first column.
I have tried
=SUMIF(A1:A20,"John",B1:E20)
which only returns the first columns number. I've also tried
=SUMPRODUCT((A1:A20="John")*(B1:E20))
but as there is text in column C, it returns #VALUE!.
A | B | C | D | E
John | 5 | Wine | 2 | 7
Sean | 6 | Beer | 5 | 2
I want all of the numeric values in columns B-E to be totalled together when "John" is in column A
Here is an array formula solution - use Ctrl, Shift and Enter to confirm:
=SUM(IF(A1:A20="John",IF(ISNUMBER(B1:E20),B1:E20)))
If you just want to exclude column C you could use this non-array formula:
=SUMPRODUCT((A1:A20="John")*(B1:B20))+SUMPRODUCT((A1:A20="John")*(D1:E20))
Alternatively, perhaps move C so it's not in the middle of your numbers.
Try this formula:
=IF(A1="John", SUMPRODUCT(--(ISNUMBER(B1:E1)),B1:E1), "")
and drag down to get sum on each row.

Excel matching multiple cells for duplicates

I need to populate a cell where the result is either valid or an error based on the following criteria. I'm not sure if using Match, Lookup formulas will work for this problem.
Given
A B C
+-----------+-----------+----------
1 | IntRef | Value | Result
2 |-----------|-----------+----------
3 | r01 | Value 123 | Success (because B4 matches B3)
4 | r01 | Value 123 | Success (because B3 matches B4)
5 | r02 | Value ABC | Failed (because B6 differs from B5)
6 | r02 | Value XYZ | Failed (because B5 differs from B6)
Success Criteria
Scan each IntRef (A) column for all duplicate keys. Where they match
on a row check the Value column (B). Where all matching cells have
the same value set their result cell (C) to Success.
Failed Criteria
Scan each IntRef (A) column for all duplicate keys. Where they match
on a row check the Value column (B). Where all matching cells have a
different value set their result cell (C) to Failed.
I am sure there is a formula that can be entered into each cell of column C which will do a lookup for each IntRef cross referencing the contents of column B where the match occurs. This is going beyond Excel formula knowledge.
Is it possible to create and help formulate the calculation of the success/failed criteria (Column C)?
This appears to do the trick...
{=IF(COUNT(IF($B$3:$B$6=B3,IF($C$3:$C$6=C3,1)))=COUNTIF($B$3:$B$6,B3),"Success","Failed")}
Note that that's an array lookup formula (meaning you need to hit Ctrl+Shift+Enter when entering it).
This formula basically counts the number of times the A and B column values appear together and compares this to the number of times the A column value appears. If the two counts match, you have success.
Try this formula:
=IF(SUMPRODUCT(IF(A2=A$2:A$9,1,0),IF(B2=B$2:B$9,1,0))>1,"Success","Fail")
Assuming you have your data like this:
Formula is entered as Array Formula in C2 by pressing Ctrl+Shift+Enter.
Then just copy on the remaining cells.
I just added and changed the position of some data for testing.
Hope this works for you. Change the Range to suit your data size.

Cell Value pickup from different sheet

I have 5 sheets in a workbook namely Sheet1, Sheet2, Sheet3.... Maintaining some data in each sheet. In first sheet namely Consolidation I need the B3 Cell value of each sheet to be displayed in each cell
Table in the Consolidation sheet will be as below
SheetNo| Name | value (Value of B3 Cell of respective sheet )
| |
1 | Party 1 | Value of Sheet1!B3
2 | Party 2 | Value of Sheet2!B3
3 | Party 3 | Value of Sheet3!B3
4 | Party 4 | Value of Sheet4!B3
:
:
N | Party N | Value of Sheetn!B3
:
:
:
Z | Party Z | Value of SheetZ!B3
I want this to be done most likely through some cell functions only not using VBA Scripting
go to your Consolidation sheet:
a1: 1, a2: 2, a3: 3 etc
a2: ="Party "&a1
a3: =INDIRECT("Sheet"&a1&"!b3")
auto fill rest
Unless I'm missing something haven't you sort of already answered it with your example?
=SheetName!Address will return the value of Address on SheetName
If you wanted it a little more dynamic so you dont have to manually fill the sheet name, you could do something like this.
=INDIRECT("Sheet" & Row() & "!$B$3")
However it will only do numeric sheet names. (unless N and Z are just numbers then theres no problem)
Just looked and saw that you've got the sheet number next in Column A so you can substitue Row() for $A$1
To refer to a cell by name, you can use the INDIRECT() function, as in:
=INDIRECT("'"&$B1&"'!$B$3")
Here, B1 is the cell containing the name of your sheet. The expression inside the parentheses will evaluate to, for example, 'Party 1'!$B$3. INDIRECT() will expand that to the actual value of cell B3 in sheet Party 1.
The extra single-quotes are required to deal with the spaces in your sheet names.

If column B cell value contains A cell value

I have two columns A and B in excel and I want third column output to be like show below
A B C
-------------------
a | sd | a.com
d | a.com |
f | g.in |
g | ad | g.in
B column has 'a.com'which contains 'a.' so C column it displays a.com
.B column doesnt have which contains 'd.' so column cell is empty and so on..
Put the following formula in column C:
=IFERROR(INDEX($B$1:$B$4,MATCH(A1,LEFT($B$1:$B$4,SEARCH(".",$B$1:$B$4)-1),0)),"")
It is an array formula, so press Ctrl-Shift-Enter instead of Enter when entering it.
Try this formula in C1 copied down
=IFERROR(VLOOKUP(A1&".*",B$1:B$4,1,0),"")
IFERROR function only works in Excel 2007 or later - for earlier excel versions try
=LOOKUP("zzz",IF({1,0},"",VLOOKUP(A1&".*",B$1:B$4,1,0)))

Resources