CONCAT or TEXTJOIN and retain commas in cell - excel

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.

Related

How to contain formulas within a formula?

I am trying to have formula return with a cell population with the first six characters of the look up cell given that the first two characters are 10.
See below for example.
=IF((LEFT(A3,2)=10), LEFT(A3,6), "")
As of right now, I keep getting a blank return no matter the look up cell's information.
This works for me:
=IF(LEFT(A3,2)="10",LEFT(A3,6),"")
LEFT returns a text string so you need ". You also don't need the double brackets.
You can aslo force the result of left() to be numerical,
=IF(LEFT(A3,2)*1=10,LEFT(A3,6),"")
I used *1, but +0 can work.
see
This can be convenient if you want to have the values like 10 or 15 etc in separate cells so you can just drag down.
See
You could use a cell to tell left() how many characters to collect or use the len() function.

Using Excel's SUMPRODUCT with SEARCH and ignoring blank cells

Suppose I have a row of cells that contain comma delimited strings like so:
I have figured out how to add the first character of each string using this formula:
=SUMPRODUCT(--(LEFT(C2:G2,SEARCH(",",C2:G2,1)-1)))
Now, I would like to extend the formula to the cell AA2, like so
=SUMPRODUCT(--(LEFT(C2:AA2,SEARCH(",",C2:AA2,1)-1)))
however, I cannot seem to get the it to ignore empty cells - it throws a #VALUE! error. I realize that I could simply update the formula each time I enter data in the subsequent cells, but that's not exactly efficient. I assume this throws an error because the SEARCH function returns a null value.
How might I get this to work?
You can try below modified formula:
=SUMPRODUCT(--(LEFT(C2:AA2&"0,",SEARCH(",",C2:AA2&"0,",1)-1)))
For right side you can use MID like below and check:
=SUMPRODUCT(--(MID(C2:AA2&".0",SEARCH(",",C2:AA2&",.0",1)+1,99)+0))
Your idea of searching for the comma is not needed if you only want to add the first character of each cell. Just grab the left-most single character.
Say we may have data from A1 to Z1 that may include some blank cells. Pick a cell and enter the array formula:
=SUM(IF(LEN(A1:Z1)>1,--LEFT(A1:Z1),0))
for example:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.

Concatenate repeats first row cell values even though formula selects different cells

I am trying to prep some zip codes to go into the WHERE clause of a SQL query:
WHERE [Zip_code] IN ()
To do this I put all the values into Excel and want to concatenate the zip codes with an apostrophe at the beginning and an apostrophe, a comma, and a space at the end so 99508 would become '99508', . So I wrote the equation
=Concatenate("'",D2,"', ") where D2 is the zipcode. It worked for the top row producing '99058', but when I filled down it still showed the value for D2
To make matters more confusing, when I click on the cells and see the formulas, they are tracking the proper cells but still show data for the top row
I have tried everything that I can think of to solve the problem: reformatting everything as text, formatting the zipcodes as Numbers rather than text, putting the text in the adjoining columns (C2 has an apostrophe, D2 has the Zip code, E2 has apostrophe, comma, and space) and concatenating, using & instead of concatenate ("'"&D2&"', " ), concatenating A on the front and B on the end to do a find and replace, but I still get the same result. If I select a concatenated cell, click on the formula bar, and press enter the cell shows the proper concatenation, but I would rather not do that for every single cell.
My co-worker suggests including that the zip codes were taken from pivot table outputs.
Any suggestions?
Turns out that calculations had somehow been set to manual instead of automatic.
Switching back to automatic solved the problem.
use this instead
=concatenate("'";D2;"',")
idk if gonna work on you sheet, bc i have in spanish my MS-office suite
but if doesn't work, replace the ; for ,
if you copy the formula to the other cells, this must change to the next row
First is clear the worksheet format
secondly, click on file on the excel, then to option, to formula after formula, check the position of the calculation. if its in automatic change it back to Manual and then change it back to automatic. That will solve it.

Concatenate numbers separated by dash while keeping leading zeros

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?

excel concatenate prefix in comma separated cell

I am horrible with excel. I rarely have to use it but today I do.
I have cells that have images that are comma separated. these cells are in the same column. i need to add a prefix lg_ to each comma separated image in the cell. I have done some reading on concatenate in excel and I am not sure if this is the right method to use. Does anyone have any good tricks/tips to accomplish this?
It currently looks like :
b3f9e6_1008a.jpg,4f57dc_1008d.jpg,9205eb_1008b.jpg,cb1c14_1008.JPG,ad8884_1008c.jpg
the result would look like this:
lg_75c552_599d.jpg,lg_a3a180_599a.jpg,lg_5c2ec4_599e.jpg,lg_dbb052_599b.jpg,lg_419420_599f.jpg,lg_8eb065_599c.jpg
note: images names are different because I just pasted what I already completed manually.
This should be on SuperUser.
What I would do is do Find..Replace on the comma and replace it with ",lg_" (without quotes). Then you need to prepend the strings with "lg_". You can do this by using another column and doing ="lg_"&A1 where you replace A1 with the proper cell reference. Drag this formula down and then copy and paste value that over the initial data.
Edit: Just because you seem new to Excel: To do Find..Replace hit Ctrl + H. The dialog box that will pop up is self explanatory.
This can also be done using the SUBSTITUTE command in a cell formula.
e.g.
Set C30 = "lg_"
Set D30 = "b3f9e6_1008a.jpg,4f57dc_1008d.jpg"
then in E30 type the following: =C30&SUBSTITUTE(D30,",",","&C30)
This does the same as ApplePie's answer, but with the added benefits that you do not need to do a manual replace, and "lg_" is not hard-coded so it can change depending upon the contents of a cell. Therefore you can copy the formula down a column and use different prefixes for each row. e.g.
IF C30="244" and D30="91,99" then E30 = "24491,24499"
IF C31="376" and D31="5,6,7" then E31 = "3765,3766,3767"

Resources