Excel formula find first character and then the numeric value - excel-formula

How can I find in the first character and then the numeric value in this string 100App100?
The formula I've used so far is below which is finding the the first numeric value. I want to return the value 100, after the App, as I want to use the formula for work for all other cells as well, example when string is FOUR200, then it would be 200. Is this possible?
=VALUE(RIGHT(B2, LEN(B2)-MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},B2&"0123456789"))+1))

1] As per your described, you can using Lookup+Right function
In C1, copied down :
=LOOKUP(9^9,0+RIGHT(B1,ROW($1:$250)))
2] Or, should you want to extract 1st group of numeric value after 1st group of text value
then in C1, copied down :
=LOOKUP(9^9,0+MID(MID(B1,AGGREGATE(15,6,FIND(CHAR(ROW($1:$26)+{64,96}),B1),1),99),MIN(FIND({0,1,2,3,4,5,6,7,8,9},MID(B1,AGGREGATE(15,6,FIND(CHAR(ROW($1:$26)+{64,96}),B1),1),99)&1/17)),ROW($1:$250)))

Related

Excel Find the first zero after a non zero within a range

I have a range, that contains data which follows a distribution *typically starts at 0, then goes up, then down, and finally back to zero.
I want to return the value of another column at the point that the data returns back to Zero (in my case you can see that Cell B6 is the point at which this event occurs, and I want my cell C2 to return the value "E" from cell A6...
Currently, the best I can get to is the following:
=INDEX(A2:B8,FIND(0,
TEXTJOIN(,,B2:B8),
MATCH(AGGREGATE(4,4,B2:B8),B2:B8,0)) -1,1)
The problem comes in with the fact that there can be any number of zeros before the data appears.
i.e. like this. = Where I would still expect the highlighted match.
1] 1st zero after a non-zero value, in C2 enter formula :
=INDEX(A:A,INDEX(MATCH(1,1/B:B),0)+1)
2] Nos. of zero after a non-zero value, in D2 enter formula :
=MATCH(9^9,B:B)-INDEX(MATCH(1,1/B:B),0)
For excel you can use INDEX/AGGREGATE:
=INDEX(A:A,AGGREGATE(15,6,ROW(B2:B8)/(B2:B8=0),2))
Edit:
If you want get first zero value after last non zero value use formula:
=INDEX(A:A,AGGREGATE(14,6,ROW(B2:B8)/(B2:B8<>0),1)+1)

match the number from comma separated value and count

I have a comma separated value in A2 and same numbers in different cells B1, C1, D1.... I want to match them from comma separated value and find out the count in B2, C2, D2. Please see the image attached you will get the context.
Can we achieve this by formula or macro in excel?
Tried formula:
=LEN(TRIM($A$2))-LEN(SUBSTITUTE(TRIM($A$2),C1,","""))
Also, I have two data sets where I will be using this formula to find out the count of number from comma-separated value and based on count I want the repeated ones to come in a different cell please refer the image for better understanding.
Probably not the best solution but get the job done. Please note it is case-sensitive and please make sure to press Ctrl+Shift+Enter upon finishing this formula.
{=SUM(--(EXACT("!"&TRIM(MID(SUBSTITUTE($A2,",",REPT(" ",100)),(ROW(INDIRECT("1:"&LEN($A2)))-1)*100+1,100)),"!"&B1)))}
You can replace ! in the above formula with a unique symbol that will never appear in the text string to be safer.
The logic is to SUBSTITUTE the comma , with and long string of blanks, then use MID to find each value in the text string and return the result as an array, then use EXACT to match each value in the array with the look up value and return a new array of TRUE and FALSE, then SUM up all TRUE which will give the count of the look up value.
UPDATE #2
As requested by OP, here is one way of solving the second query which is to match the same value with the same occurrence from two text strings separated by comma ,.
The formula in Cell C2 is from the original solution which is used to find the occurrence of a given value in a text string;
The formula for Range C6:K6 is an array formula as shown below. I used a helper row to layout the matching values, and excluding the one that has 0 count for both data set;
{=IFERROR(INDEX($C$1:$K$1,,AGGREGATE(15,7,COLUMN(INDIRECT("1:"&COLUMNS($C$1:$K$1)))/($C$2:$K$2=$C$3:$K$3)/($C$2:$K$2>0),COLUMN()-2))&",","")}
The formula in Cell L8 is concatenating all values from Range C6:K6 and remove the last comma , from the final text string:
=LEFT(CONCATENATE(C6,D6,E6,F6,G6,H6,I6,J6,K6),LEN(CONCATENATE(C6,D6,E6,F6,G6,H6,I6,J6,K6))-1)
The following worked for me, give it a try:
Formula in B2:
=(LEN(","&SUBSTITUTE($A$2,",",",,")&",")-LEN(SUBSTITUTE(","&SUBSTITUTE($A$2,",",",,")&",",","&B$1&",","")))/LEN(","&B$1&",")
Drag right...
A simpler way of doing it is to simply calculate the difference in the length of the string minus the length of the string when replacing the value searched by nothing and dividing by the length of the string searched
The formula would be:
=(LEN($A$1)+1-LEN(SUBSTITUTE($A$1&",",B1&",","")))/LEN(B1&",")
There is a much simpler solution:
=COUNTIF(SPLIT($A$2, ","), B1)

Excel lookup value in rightmost alphanumeric cell in row

I imagine that I have a row with two kinds of alphanumeric values, one that has 0, and another that has a digit above 0.
If I want to find the rightmost cell that has a value above 0 such as 1, what would the formula be?
Currently I am using the formula =IFERROR(LOOKUP(2,1/(A2:O2<>""),A2:O2),"NS")
but it returns MB0 instead of HB1.
I'd suggest trying like below if number part is always rightmost part of the string.
=IFERROR(LOOKUP(2,1/RIGHT(A2:O2),A2:O2),"NS")

Sum all value of row when find a specific word in a column

I want to sum all values of one row (there are a lot of column) if there is a specific value in the first column.
Below follow the problem:
Link with the image
I want to find API Rheology and then find Cond. Time, with verified this two conditions, sum all values of the row.
    
You need to check the value of the first column with an "IF" function, and then if it's true, use "SUM" to find the total.
For example, if your first column is in a1, and your data goes from a1 to z1, than your formula should look like this:
=IF(A1="[check value]",SUM(A1:Z1),"")
Where you replace [check value] with what value you are looking for and "" with what you want to display if the value is not there. Putting "" will leave the cell blank.
If you want to be more specific and check if the first column contains a value, then you need to use:
=IF(ISNUMBER(SEARCH("[check value]",A1)),SUM(A1:Z1),"")
With the same arguments as before.
If you want to find multiple values than you need to use the AND function, so your function becomes:
=IF(AND(ISNUMBER(SEARCH("[check value]",A1)),ISNUMBER(SEARCH("[check value 2]",A1))),SUM(A1:Z1),"")
This will check if cell A1 contains both strings. If you want to check two different cells, then just replace the second A1 with whatever other cell you want.
If you want to find the string within a column of cells, replace the "A1"s with the list of cells you are looking for the string in. e.g. A1:Z1
The reason this works is because SEARCH returns a number based on where the [check value] is found within cell A1, or an error if the string doesn't appear. ISNUMBER returns TRUE if SEARCH return a number, not an error. Finally, IF checks if ISNUMBER is true or false, and returns the sum of your numbers if true and a blank space if not.
Hope this helped.
The sample data image seemed incomplete so I added a few things.
    
The formula in AE65 is,
  
This formula looks down column A for the name of the test (e.g. API Rheology in AC65) then locates the next occurrence of the reported result section (e.g. Cond Time (min) from AD65). Having located that row, it sums columns C:Z.

Have formula treat value as text, not numeric

I have an Excel formula reading data from a column. The data in that column is sometimes a date-like format, such as "10-11". Despite the fact that I've ensured that column is text formatted -- and all values display correctly as plain text, not reinterpreted as dates -- the formula is basically reinterpreting them as dates in the reference.
I need a way to force the formula's cell reference to interpret the cell as text. I tried TEXT(A1, "#") but it doesn't work -- it gives the numeric value of the date.
Brian Camire's answer explains why, but here's a worksheet function that will work for you. Note that you have to create that numeric array in it based on how long the longest string will be. It's an array formula, so when you first enter it you have to hit CTRL-SHIFT-ENTER, then you can click and drag it down the column.
=LEFT(A1, MATCH(FALSE, ISNUMBER(VALUE(MID(A1, {1,2,3,4,5}, 1))),0) - 1)
Short answer: When referring to number-like (or date-like) text values in a formula, don't use them in a place in the formula where Excel is expecting a number.
Long answer: Even if the source column is formatted as text and the values in the source column are truly entered as text (and not numbers, including dates), Excel may automatically convert text values to numbers (including dates) when you reference them in a formula if you use them in a place where Excel is expecting a number (or date).
For example (assuming US date formats), in a blank worksheet:
Set the format for column A to Text.
In cell A1, enter the value 10-11.
In cell B1, enter the formula =T(A1). The T() worksheet function returns the supplied value if it is text. Otherwise, it returns an empty string. The result of the formula in cell B1 should be 10-11, indicating that the value of A1 is text, not a number or date (in which case the result would be an empty string).
In cell C1, enter the formula =A1.
In cell D1, enter the formula =T(C1). The result should also be 10-11, indicating that the value of the formula in C1 is text, not a number or date. This shows that you can (sometimes) use a text value that looks like a number (or date) in a formula and have Excel treat it as text (which is what you want).
In cell E1, enter the formula =A1+0. The result will be 40827. This is the numeric value of the date October 11, 2011. This shows that you can (sometimes) use a text value that looks like a number (or date) in a formula and Excel will automatically convert it to a number (which is what you observed) if you use it in a place (like on either side of the + operator) where Excel is expecting a number.
To insert a value into a cell and have it not be auto-formatted, and just treated as text, you can enter it like this:
=("cell data")
eg:
=("+1 3456789")
When you use &"", Excel converts the results of a formula to text (like *1 would convert to numbers).
Thus, you can use this formula:
=TEXT(A1;"jj-mm")&""
If you put a single quote in front of the text in the cell, it should be represented as text on all references:
'10-11
Just add zero to the input!
I was having a similar problem where I had a list of numbers with a text prefix (like FOO-1, FOO-25, FOO-979) but I just wanted the number part (1, 25, 979) so I could run another formula off of that. I was using SUBSTITUTE to replace the text portion with blank, but my other formula using these numbers was coming up with bogus results. I ended up making my formula like this:
=SUBSTITUTE(B1:B10,"FOO-","")+0, and now the ISNUMBER is saying TRUE where before it was saying FALSE.
In my case, I have a form worksheet that is used by dealers to ad parts and have it calculate the final cost; it references a locked "products" sheet. The problem is that I had no way of controlling what they entered.
Products can be like:
101 = A true number
7-2009 = Reads as date
7-5601-RT = TEXT/NUMBER reads as both number or text (NOT SOLVED YET)
CP6072CD = reads as plain text
I have most of this figured out; the only one that isn't is the one that reads as both text/Number.
In case anyone is looking for a similar solution, i did the following:
I created three additional columns to test and display the three different cases: "NUMBER", "DATE" , "TEXT".
DATE: =NOT(ISERROR(DATEVALUE(B42)))
ISOTHER: =(ISNUMBER(--(MID(B42,ROW(INDIRECT("1:"&LEN(B42))),1))))
NUMBER: =ISNUMBER(B42)
NUMBER/TEXT: =NOT SOLVED YET
I42 = DATE
J42 = NUMBER
K42 = OTHER
L42 = TEXT
M42 = THE RESULT OF THE QUERY BELOW
=IF(AND(I42 = FALSE, J42 = FALSE, K42 = TRUE), "NUMBER", IF(AND( I42 = TRUE, J42= FALSE, K42=TRUE), "DATE", "TEXT"))
This (ABOVE) tests all the true/false results and depending on what the value turns out to be, I format each of them using:
ISNUMBER = VALUE(B42)
DATE FORMATTED AS B42*1
ELSE TEXT - AS ORIGINAL
=IF(M42 = "NUMBER", VALUE(B42), IF(M42 = "DATE", B42*1, B42))
So now I just need to figure out how to test if something is both text and number because the 7-5601-RT tests out as the same as number: "FALSE, FALSE, TRUE, TRUE"

Resources