Excel: Given a cell in column B as input, how could I find out the lowest cell of A which B > A? - excel

I have an excel sheet, which value of column A >= B in the same row.
I would like to know given a cell in column B, how could I find out the lowest cell of A which B > A? (It should return a cell address but not the value)
For example, the following shows cells from A1 to B7 in a sheet:
A B
------
1 | 1 1
2 | 3 2
3 | 5 3
4 | 7 4
5 | 9 5
6 | 10 6
7 | 15 10
Now I would like to input B6, then it should return A3 (since 6 > 5)
Another example, if I input B7, then it should return A5 (since 10 > 9)
Is there any approach (or similar approach) by using excel formula? Or should I use other methods?

If your input value is in cell E1, and your return value is in cell E2 (as shown in below image), then you can use this formula in cell E2:
=IF(E1="","",INDEX(A1:A7,MAX(1,MATCH(TRUE,INDEX(A1:A7>=E1,),0)-1)))

Input Cell E1 (enter the address from column B here)
F1: =ADDRESS(LOOKUP(2,1/(INDIRECT(E1)>ColA),ROW(ColA)),1,4)
Given your data, if you enter B6 in E1, A3 will show in F1

Related

How to get next not empty cell in excel

How do i manage to get the row number of the next not empty cell in relation to the current cell?
I do not want to use vba!
| A | B |
1 X 3 (expected result)
2
3
4 X 7 (expected result)
5
6
7
8 X
If my formular is located in cell B3, how do i get the row number of the next not empty cell in col A starting from A3?
Try this formula in B1 and copy down:
=IF(A1="","",MATCH(TRUE,INDEX((A2:A$100<>0),0),0)+ROW(A1)-1)
Change A$100 as you need

Add A1 to C1 if B1 = Specific Number

I will try to be as clear and concise as possible. I am working on a spreadsheet in which I have item prices listed in a range of A1:A40. B1:B40 lists a numerical digit (either 1, 2, 3, etc.) that corresponds with a purchase category type (groceries, gas, etc.). Now I want one cell, such as C1, to add all instances in the A range that equal a specific number in B.
For example:
A1 = $5.00 | B1 = 1 | C1 = The sum in range A1:A3 if it's corresponding B value is equal to 1 (In this case B1 and B3, so C1=A1+A3)
A2 = $2.50 | B2 = 2 | C2 = The sum in range A1:A3 if it's corresponding B value is equal to 2 (In this case B2, so C2= B2)
A3 = $4.00 | B3 = 1 | C3 =
Use SUMIF Function
SUMIF(range, criteria, [sum_range])
In Cell C1 enter the formula = SUMIF(B:B,1,A:A)

Sum fields in a column if there is an entry in a corresponding row in another column

Assume the following data:
| A B C
--+------------------------
1 | 2 3 5
2 | 2 3
3 | 4 4
4 | 2 3
5 | 5 6
In cell A6, I want Excel to add cells C1, C2, C3 on the basis that A1, A2 and A3 have data in. Similarly, I want B6 to add together C1, C4 and C5 because B1, B4 and B5 have data.
Can someone help?
In A6 enter:
=SUMPRODUCT(($C1:$C5)*(A1:A5<>""))
and then copy to B6:
A simple SUMIF formula will work
=SUMIF(A$1:A$5,"<>",$C$1:$C$5)
Place that formula is cell A6 and then copy it to B6.
You can create another column, e.g. AValue, with the formula =IF(ISBLANK(A1),0,A1) in it. This will return 0 if the cell in A in the corresponding line is empty, or the value from the cell in A otherwise.
Then you can just sum up the values of the new column.

extract data from column based on subset of data from other other column

This is how my data looks like:
C1 C2 C3
1 1 a
2 2 a
3 3 a
4 4 a
7 5 a
8 6 a
9 7 a
10 8 a
9 a
10 b
You see that C1 is a subset of column C2. I want now to extract only the data from C2 - together with the corresponding value from C3 - that matches C1. The extracted data just needs to be copied to another column
Could someone give me a hand?
Assuming your data in C1 starts from A2, do the following:
Type in cell D2 (column C4): =IFERROR(VLOOKUP($A2,$B:$C,1,0),"")
Type in cell E2 (column C5): =IFERROR(VLOOKUP($A2,$B:$C,2,0),"")
Autofill both formulas.
This will give you what you want, missing values will be shown as blanks. If you want concatenate both parts of out - just put the aggregate formula =ISERROR(...)&ISERROR(...) to any column row 2 you like.
Sample file: https://www.dropbox.com/s/qglyxmu3tkfxy7g/DataExtract2Cols.xlsx

formula for finding the first non-empty cell

I have a spreadsheet with 2 columns of data, column A and B, and column C where I'm looking for the formula.
row A B C
1 50
2
3
4
5 56 6
6
7
8 46 10
9
10
11 64 18
As you can see, a row either contains a value or not. In column C, I'm looking to calculate the difference between
a) the value in column B and the value in column A's first non-empty cell directly above (so for example, at row 5, I calculate the difference between B5 and A1 56 - 50 = 6) if the value of B is a number and
b) the value in column A and the value in column B's first non-empty cell directly above (row 8, 56 - 46 = 10)
and put nothing if neither column A and B are empty.
I've been struggling with "first non-empty cell" to write an R1C1 formula. Note that I know I can do this in VBA but I'm looking for the R1C1 formula.
Thanks for your help.
Here is an array formula (that you need to validate with Ctrl + Shift + Enter) you can put in C1 and drag and drop till the end of your data:
=IF(OR(A1<>"",B1<>""),INDEX($B$1:B1,MAX(IF($B$1:B1="",0,ROW($B$1:B1))))-INDEX($A$1:A1,MAX(IF($A$1:A1="",0,ROW($A$1:A1)))),"")
Or, in a french version of Excel:
=SI(OU(A1<>"";B1<>"");INDEX($B$1:B1;MAX(SI($B$1:B1="";0;LIGNE($B$1:B1))))-INDEX($A$1:A1;MAX(SI($A$1:A1="";0;LIGNE($A$1:A1))));"")
Note that if you feel interested, you can commit into Stackoverflow in french
Perhaps try this formula in C2 copied down
=IF(B2="",IF(A2="","",LOOKUP(9.99E+307,B$1:B1)-A2),B2-LOOKUP(9.99E+307,A$1:A1))

Resources