Concatenate numbers separated by dash while keeping leading zeros - excel

I have two columns in Excel with leading zeros that I want to concatenate. The below code works perfectly. It concatenates the columns and retains the leading zeros from each column:
= A2&B2
However, I need a dash between the values. When I alter the formula to the following the leading zeros to the right of the dash are removed:
= A2&-B2
How do I add that dash while retaining all leading zeros?

Use Excel's CONCATENATE formula.
=CONCATENATE(A2,"-",B2)
Here, I use 00df9 in cell A2 and 00asd in cell B2 with a result of 00df9-00asd

if I've used two separate formulas using concatenate into one cell and both or one brings answer with decimals, how can I format to limit or remove (roundoff) the result numbers?
Here's the formula:
=CONCATENATE((F2/4.2),"/",((F2/4.2)/7))
and here's the example result: 273.809523809524/39.1156462585034
Now, for me, the idea solution is that the cell shows 234/39. Basically how (if at all) can I format that cell with concatenate formula?

Related

CONCAT or TEXTJOIN and retain commas in cell

I am trying to concat the ROWID of a cell to a string of numbers and retain the commas. Works fine when no commas are present but if they are, it deletes them and makes it one long jumbled number. See screenshot. What am I missing?
Formula
Googled to no avail. I want cell H37 to read 2,164,216,521,662,160,-18 instead it reads 2164216521662160,-18.

Convert text string into a formula in Excel

I have in a cell two numbers "=5+4" as a text. This is a result of another operation.
I took a part of another formula and concatenated it with "equal" symbol:
= "=" & RIGHT(FORMULATEXT(V8);LEN(FORMULATEXT(V8))-SEARCH("+"; FORMULATEXT(V8)))
I want to get the result of 5+4 in a cell- which means "9" ;)
I DO NOT WANT TO USE VBA code.
my initial problem was to extract all numbers except the first one from an equation and sum in another cell: A1: "=6+5+4". A2: "9". Maybe it can be solved without VBA?
You could try (assuming only addition):
Formula in B1:
=SUM(FILTERXML("<t><s>"&SUBSTITUTE(MID(A1,2,LEN(A1)),"+","</s><s>")&"</s></t>","//s[position()>1]"))
In fact, if you don't want to use the 1st number we could also discard taking '=' into account:
=SUM(FILTERXML("<t><s>"&SUBSTITUTE(A1,"+","</s><s>")&"</s></t>","//s[position()>1]"))
And since SUM() will ignore text in the final answer, we can now even further simplify this (thanks #JosWoolley):
=SUM(FILTERXML("<t><s>"&SUBSTITUTE(A1,"+","</s><s>")&"</s></t>","//s"))
If you are always adding 2 numbers, then you can use this:
=VALUE(VALUE(MID(A1;2;SEARCH("+";A1)-2))+VALUE(MID(A1;SEARCH("+";A1)+1;9999)))
My column A is formatted as text, and all values follow same pattern: =Value1+Value2
So the formula extracts Value1 and Value2 as text with MID functions, based on the position of + symbol. Then Excel convert both values into numeric with VALUE function. Notice there are 3 values, the third one is to make sure the cell stays at standar format (in some versions of Excel, like mine 2007, when involving text formatted cells into formulas, the formulated cell autoformat itself to text format, making the formula to work just once).
As you can see in the image, it works perfectly but this is just for pattern =Value1+Value2. For different patters you'll need different formulas.
If you want to make a formula to work with all patterns, then indeed you need VBA.

Excel lookup every word in a cell and match with a list

I am trying to come up with a excel formula to Look Up every word separated by either a space or comma in a cell, match each of the words against a list of words and return the found word in another column.
As an example:
So the ColorFamily column should be a formula
I have tried using VLOOKUP e.g.
=VLOOKUP(H3,color_family!$A$3:$A$19,1,FALSE)
But the limitation is that it does not iterate through every single word in the cell. Is it possible to do this using Excel Formula or is VBA required?
Enter as an array formula (ctrl+shift+enter):
=TEXTJOIN(" ",TRUE,IF(ISERR(FIND(color_family!$A$3:$A$19,H3)),"",color_family!$A$3:$A$19))
I couldn't make much sense of the accepted answer but here is a similar approach. This works in Excel 365, and depends on its dynamic array functionality to work.
Here is the spreadsheet layout I am working with:
I have used spaces to separate the values in the colour list but the solution could be generalised to handle commas etc.
The steps I've used to build the formula needed are:
Group valid list into a single string using TEXTJOIN: TEXTJOIN(",",TRUE,$A$7:$A$9)
Split the Colour cells into columns of words (uses dynamic array functionality). There is a write up on how to do this here: https://www.mrexcel.com/board/excel-articles/split-text-cell-into-columns-of-words.19/ e.g. for A2 this formula produces Black and Red in separate columns
TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",LEN(A2))),SEQUENCE(1,LEN(A2)-LEN(SUBSTITUTE(A2," ",""))+1,1,LEN(A2)),LEN(A2)))
Use FIND to look for the text in each column above, in the valid list
If FIND returns a number (checking with ISNUMBER) return the text, otherwise ""
This is all still in separate columns so now use TEXTJOIN to combine the results together in a comma separated list.
Final formula in B2:
`=TEXTJOIN(",",TRUE,IF(ISNUMBER(FIND(TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",LEN(A2))),SEQUENCE(1,LEN(A2)-LEN(SUBSTITUTE(A2," ",""))+1,1,LEN(A2)),LEN(A2))),TEXTJOIN(",",TRUE,$A$7:$A$9))),TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",LEN(A2))),SEQUENCE(1,LEN(A2)-LEN(SUBSTITUTE(A2," ",""))+1,1,LEN(A2)),LEN(A2))),""))`
which can be copied into B3, B4 etc giving final result:

need hyphen instead of zero in my excel formula

I want to add some values in my excel sheet , but when there is no value want hyphen instead of zero .
Here is my formula as below :
=IFERROR(SUMIF(A1:A6,"="&VLOOKUP($F$3,A1:B6,1,FALSE),B1:B6),"-")
The formula for that'd be:
=IFERROR(IF(SUMIF(A1:A6,"="&VLOOKUP($F$3,A1:B6,1,FALSE),B1:B6)=0,"-",SUMIF(A1:A6,"="&VLOOKUP($F$3,A1:B6,1,FALSE),B1:B6)),"-")
But I suspect you just want to change the number format to ACCOUNTING... it automatically replaces zeros with hyphens.

How to bring in string from left of numbers in Excel

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

Resources