Microsoft Excel - Search and find the next highest value - excel

I am not an Excel expert and I need some help.
I have a list of different numbers and a reference number. I have a formula where it gives me the closest value of my number from this list
Example:
10
11
16
20
30
My reference number is 13.
I have found online a formula that gives me the closest number which in this case is the number 11.
=INDEX(list;MATCH(MIN(ABS(list-reference_number));ABS(list-reference_number);0))
But I want the result to be 16 (the next highest number).
I would like to know if this is possible and how can I achieve it.
Thanks in advance!

Since MATCH(refernce,list) will return the closest to 13. That means MATCH(refernce,list)+1 will return the result you looking for:
Formula in to use:
=INDEX(C1:C5,MATCH(13,C1:C5)+1)

Here's another Array formula for you to try (Ctrl+Shift+Enter):
=SUMPRODUCT(MIN(IF(A1:A5-B1>0,A1:A5)))

Provided column A contains the numbers, which can be unsortet by the way, you can get the closest higher number with:
{=MIN(IF($A:$A>B1,$A:$A,MAX($A:$A)+1))}
B1 contains the reference number (in your case 13).
Note: This is an array formular. You don't have to enter the curly braces. Instead paste the formular without { and } and press Ctrl + Shift + Enter to confirm your input.

Related

Look up value by the lowest value

I am trying to match specific name (the names may be repeated several times) and to look up the name which has the lowest value in column D
Here's a snapshot to illustrate the issue
I would like for example to lookup the name Name1 and return the one who has the lowest value. In this case I need to return the row number 4 as this one has only 12 in value
I tried such a formula but didn't work for me
=MATCH("Name2",$A$2:$A$9,MATCH(MIN($D$2:$D$9),$D$2:$D$9,0))
You may use:
=MATCH(1,(A1:A9="Name1")*(D1:D9=MIN(IF(A1:A9="Name1",D1:D9))),0)
Note: It's an array entered formula using CtrlShiftEnter.
If you have Office 365, you can use the new XMatch function with an array returned by an IF statement. Like this formula, which assumes that the text "Name1" is in cell F1.
=XMATCH(0,IF(A1:A9=F1,D1:D9,NA()),1,1)
edit after comment: If you can't use Xmatch, then the data needs to be sorted by column D values from large to small. Then you can use Match() with a -1 as the last argument to look up the next value larger than 0. XMatch can do that with unsorted data, but Match needs sorted data for that.
Also, if you don't use Office 365, the formula needs to be confirmed with Ctrl + Shift + Enter, because it is an array formula. If you enter it in Office 365 Excel, that's not needed, but if people edit the workbook with an older version of Excel and edit the formula, they need to use Ctrl + Shift + Enter.

How to extract text from excel cell

having this data in excel cell
kerass(xcvbn=2, abcdefg_iD='510863005')
having 100000 of records so, how to extract id number using excel formula from that excel sheet
Thanks in advance
Assuming your value is in cell A2. Here is a formula to be inserted
=SUBSTITUTE(RIGHT(A2,LEN(A2)-SEARCH("_iD='",A2)-4),"')","")
This means:
Search for "_iD='"
Once found, subtract the length of "_iD='" of that location (hence the 4)
Use the total length of the string, subtracted with location and 4, in order to find where the actual identifier begins
Take the right part of the string, only the part behind "_id='...'" remains
In that part, replace "')" by an empty string (otherwise you get "...005')"
Alternative answer:
=MID(A1,FIND("'",A1)+1,9)
The find formula finds the first "'" starting position
Assuming all the ID's are 9 digits, the MID formula uses the starting pos. from find and takes the following 9 digits.
So assuming your text is in cell A2, and that the id is the first 9 characters of the last 11 then this is the simplest I can think of:
=LEFT(RIGHT(A2,11),9)
But if extra characters get added or the ID changes length.
Does have the benefit of being minimalist on functions and low volativity.

Excel formula that use while to get a 1 digit number

So I have to get in a cell a single digit number.If I get 92 I need to do 2+9=11 and after 1+1 =2 so 2 is my number.How I can do this with a single function?
Simply:
=1+MOD(A1-1,9)
Regards
You need to first validate the cell value by using below formula
=COUNT(FIND({0,1,2,3,4,5,6,7,8,9},A1))>0
if above is true then only use below formula to get your number
=left(A1,1)
=right(A1,1)
Store into a variable and than try to read digit if more than 2. May be this is helpful.

Return the line and column of the value imeadtly higher than a given one

I want to get the value of a - column G - and b - line 2- in two different cells that correspond to the number imeadtly higher than the one given in one cell, ex: E7.
Basically i want to look for the value, imeadtly higher to a given one, in a matrix and i'm looking for the formula that gives me the correspondent value of the line and the column.
prntscr.com/7nza32
If the given value is 121 i want the answer for a to be 125 and for b to be 100
Can anyone please help me?
Please consider the following solution. Note that when Curly brackets are used ({ and }) this represents that formula is inputted as array formula using CTRL + SHIFT + ENTER.
To find the smallest value that is higher than E7:
F7 {=MIN(IF(E7<H3:K10,H3:K10,""))}
To find value in A:
F8 {=SUM(IF(H3:K10=F7,G3:G10,""))}
To find value in B:
F9 {=SUM(IF(H3:K10=F7,H2:K2,""))}
Regards,

how to add zeros after numbers to get a fix length in EXCEL

I have 3 numbers in excel.
A1. 498
A2. 899
A3. 5209
I want the numbers as the followings:
B1. 49800
B2. 89900
B3. 52090
I am still finding the solutions via online but most of the resource is discussing about leading zeros.
Please, could you kindly give me any ideas? Thanks.
I hope this formula may be of some use:
=A1 & REPT("0"; 5 - LEN(A1))
Thought this does not set the format of the cell itself (which I doubt can be done as you are changing the value of the cell by adding the zeros)
The formula only works if you are dealing with numbers as text, so you may need to convert them to text in the formula (TEXT(A1; "0") instead of A1)
you can do this one quite easily without VBA - using an IF and the very handy REPT function:
=IF(LEN(H13)<5,H13&REPT(0,5-LEN(H13)),H13)
Essentially - if the length is less than 5 - you repeat 0 up to the amount of times that its missing.
Seems like simple math to me. Essentially you want to shift left (base 10) a certain number of times. We can do this by:
Calculate the ceiling of the base-10 logarithm of the value to get it's "length"
Subtract the result from the target "length" of 5, this is the number of places we want to shift
Take 10 to this power and multiply back by the value.
In other words, where x represents the value in column A you want to transform:
In Excel, this would be expressed as:
=A1*POWER(10,(5-CEILING(LOG10(A1),1)))

Resources