How to bring in string from left of numbers in Excel - string

I'm trying to format a column based off of another (let's say column B2). The column contains a value like "ABC011" and I need to bring in just the letters "ABC".
For another column I also need to bring in just the numbers "011" but without the trailing zeroes (although I imagine that if I can get the solution for the first question I'll be able to figure out the second).
Thanks in advance.
EDIT: The length of the characters can change but the numbers are USUALLY 2 or more digits as well as the letters.

To isolate the first characters from the numbers, in C2 this array formula:
=MID(B2,1,MIN(IF(ISNUMBER(SEARCH({0,1,2,3,4,5,6,7,8,9},B2)),SEARCH({0,1,2,3,4,5,6,7,8,9},B2)))-1)
Being an array formula it must be confirmed with Ctrl-Shift-Enter when leaving edit mode. If done correctly then Excel will put {} around the formula.
If you have excel 2010 or later you can use this non CSE Formula instead of the one above. It does not require the Ctrl-Shift-Enter:
=MID(B2,1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},B2),1)-1)
Then using that result in D2 we put:
=RIGHT(B2,LEN(B2)-LEN(C2))
This will put it in as a string, if yo want to make it a number just put -- in front:
=--RIGHT(B2,LEN(B2)-LEN(C2))
This will return the number as a number so 011 will become 11
To get the numbers

Related

Use SUMPRODUCT when field is blank from formula and dates

I have two columns in my excel, Date 1 in A and Date 2 in B. I'm trying to find the number of times Column B is greater than Column A. I'm using the formula =SUMPRODUCT(((B2:B5-$A$2:$A$5)>0)*1) and receiving an error. The error is due to the data in Column B is being pulled in from a formula, where my value_if_false is "". While the cell is blank, Excel sees this as data and will not execute my original formula.
If I go to B4 and delete the value, my original SUMPRODUCT will execute. I'd like not have to go back and do that. I've tried =SUMPRODUCT((NOT(ISBLANK(B2:B5-$A$2:$A$5)>0))*1) but it's returning 0. Any suggestions?
Try following array formula:
{=SUMPRODUCT((IF(IFERROR(VALUE(B2:B5);FALSE); B2:B5;0)>$A$2:$A$5)*1)}
Array formula after editing is confirmed by pressing ctrl + shift + enter
Writing "" (nul string) to a cell that is supposed to contain a number (such as a date) is never a good idea because it leads to problems like this one. The solution is in not writing a string (text) to a numeric field. Write zero instead, and then deal with the display of zeros via global settings or cell formatting.
Of course, any date would be greater than zero. If this leads to the wrong count the obvious remedy would be to make a second count of instances where zero is involved and deduct the result of the second count from the first, like, SUMPRODUCT(1)-SUMPRODUCT(2)
I guess if you wanted to stick with SUMPRODUCT and avoid array entry, you could try
=SUMPRODUCT((B2:B5<>"")*(B2:B5>A2:A5))
or to exclude anything except a number (which in this case would be formatted as a date)
=SUMPRODUCT(ISNUMBER(B2:B5)*(B2:B5>A2:A5))
is possibly better.
B4 contains "", not ="".

How to sum several bracket-surrounded numbers of a single cell with Excel formula?

I have one cell containing several lines, including numbers inside brackets, which I want to sum-up with a single Excel formula (no VBA).
The following approach already works for single bracket:
https://exceljet.net/formula/extract-text-between-parentheses
But I need extended approach... here an example for the content of one single Excel cell to which I search for an formula, which should result in sum of "8":
The task requires following effort (incl. documentation)
- create plan (2h)
- execute test (14h)
- write report (draft) (2h)
Possible approach: The formula should search for all numbers inside the mask <"(" x "h)">, where x must be summed-up.
UPDATE: The formula should also work with numbers >=10.
UPDATE2: It should also work in case there are other comments in brackets, also after presence of first (xh) number. See "(draft)" in example, last row.
Borrow the formula from this post #6 (https://www.mrexcel.com/forum/excel-questions/362184-extracting-multiple-numbers-string.html) and modified to fit your need (single cell formula). Assuming you are going to enter the formula in cell B1:
{=SUM(VALUE(MID(0&A1,LARGE(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))*ROW(INDIRECT("1:"&LEN(A1))),ROW(INDIRECT("1:"&LEN(A1))))+1,1)))}
Basically this is to assign each character with its index and then get the numeric value to sum up. Please note this is an array formula. Please click Ctrl + Shift + Enter together.
REVISED:
Here is the array formula (click Ctrl + Shift + Enter together) to extract two-digit numbers:
{=SUMPRODUCT(IFERROR(0+("0"&TRIM(MID(SUBSTITUTE(SUBSTITUTE(S‌​UBSTITUTE(LOWER(MID(‌​‌​A1,SEARCH("h)",A1)‌​-4,LEN(A1))),"h","")‌​,")","("),"(",REPT(" ",1000)),ROW(INDIRECT("1:20"))*2*1000-999,1000))),0))}
What this does is to massage the text first by removing unnecessary content, remove h wording and convert ) to 999 blanks. Then you can extract numbers and add up. IFERROR will made the anything not numbers to 0. Hope this can solve your problem.
I appreciate that this is not in any way elegant, however it is working. I do not have time to run through the logic here right now (might edit it in later though) but essentially it is a load of search index logic.
I have Used 5 columns for each formula which assumes a maximum of 5 values but you can adjust this as needed by dragging the formula over more columns as it will begin looking for the next "(?h)" after the previous column's found value.
Red cell formula: =SEARCH("(?h)",$A1)&" - "&SEARCH("h)",$A1)
Orange cell formula: =SEARCH("(?h)",$A1,MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)+1))*1)&" - "&SEARCH("h)",$A1,MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)+1))+1)
Yellow cell formula: =MID($A1,LEFT(B1,SEARCH(" - ",B1))+1,((MID(B1,SEARCH("- ",B1)+2,LEN(B1)-(SEARCH("- ",B1)))*1)-(LEFT(B1,SEARCH(" - ",B1))*1))-1)*1
Green cell formula: =SUMIF(G1:K1,">="&0)

Excel Find the max length of characters after decimal in a given column

I'm trying to find a way to get the max number of characters after the decimal place in a given column. For example
I found this to get the max length in a column (using ctrl+shift+enter):
=MAX(LEN(A1:A5))
And this formula to get the number of characters after the decimal for a single cell:
=LEN(A1)-FIND(".",A1)
But I need to combine the two into a single formula so that I don't need another column of data. Is this possible without VBA?
Edit, one example I might encounter would be 99.999 vs 100.12 that I'd need to differentiate between and result in a length of 3 characters after the decimal.
If any of your data is the result of formulas, you may have some surprising results and need to use VBA. Otherwise, so long as the format is General, you can use
=MAX(LEN(A1:A5)-FIND(".",A1:A5&"."),0)
confirmed by holding down ctrl+shift while hitting enter
You can use Array Formulas in conjunction with some of your original suggestions to accomplish this. The formula in the example you provided would be:
{=MAX(IFERROR(LEN(B1:B3)-FIND(".",B1:B3),0))}
Some notes:
The "IFERROR" function is used to return a 0 to the MAX function if the "." is not found in the string
Array formulas can be entered into excel by entering the text "=MAX(IFERROR(LEN(B1:B3)-FIND(".",B1:B3),0))" into the formula bar and pressing ctrl+shift+enter (at which point the curly brackets will appear)
Applying this formula should yeild the following results for your sample inputs:
Sample Results

Excel - float number cannot be summed

I have a bunch of values like 0.5, 1.0, 1.5 etc.
I want to write a SUM function for those cells but the value is 0.
If I use integers the summing works so there is something with the nbrs that is wrong. Maybe they are strings?
Because they end up to the left in the cell instead of the right like integers.
What do I need to do?
=SUM(H22:H26)
Fell on the issue today: I exported data that I pasted into Excel. The formula =SUM(B:B) supposed to sum my decimals kept on returning 0...
It's stupid, but it made me lose 5 minutes: the decimal separator . had to be replaced by , or Excel wouldn't understand it as a decimal number.
Of course, it depends on Excel/system regional settings.
In a new column, try multiplying the original column by 1; then sum the new column. Not sure, but that may fix the issue.
Convert the numbers to values first with
=value(H22), =value(H23), etc.
in column G and then do
=SUM(G22:G26)
Alternatively, you can just do
{=SUM(VALUE(H22:H26))}
Notice this is an array formula, so select it and hit F2 and then CTRL-SHIFT-ENTER
Especially if the data came from a web page or HTML document, try the following
This formula must be array-entered:
=SUM(IFERROR(--TRIM(SUBSTITUTE(A1:A100,CHAR(160),"")),0))
To array-enter a formula, after entering
the formula into the cell or formula bar, hold down
< ctrl >< shift > while hitting < enter >. If you did this
correctly, Excel will place braces {...} around the formula.
HTML frequently adds the NBSP character for spacing, and that must be removed specifically before Excel will see the value as a number.
If you want to do this in one cell, basically you should convert values and sum them
=VALUE(SUM(H22:H26))
Tried and verified!

Excel Mass Number Checking?

I have an Excel file with over 5k+ rows and numbers.
I want to check these 5k+ numbers to see whether they have any "problems" within them (not errors such as #DIV/0, etc, those have already been accounted for).
So for example...a problem would be having a space in front of a number, causing that number to not be added to the sum of all numbers, etc... not logical errors, but more input errors. iserror would not work in this case, as it isn't a logical error.
Is there a way to do this automatically? Thanks!
Suppose all your numbers are in column A, starting at A1.
You could then in B1 put in the formula =Value(A1) and drag it down.
Then, just filter column B for #VALUE - That will give you all the numbers from column A that aren't seen by Excel as numeric.
Hope this helps!
On testing, Value() does its best to convert a value to a number, ignoring initial spaces or an apostrophe. I might use =ISNUMBER() in preference.
If you highlight the cells, say A2 downwards, you can create a Conditional Formatting, New Rule, Use a Formula, and enter =ISNUMBER(A2); choose some formatting for these cells.

Resources