Excel - Find and replace those comma not within parenthesis - excel

I have rows on my excel that has following values below.
Brandon (39042, 39047),Pearl (39208),Fondren and Belhaven,North Jackson (39206,39211),Byram (39272),South Jackson (39212, (39204),Clinton (39056),Madison (39110),Ridgeland (39157),West Jackson (39209)
What I'm trying to accomplish is change the comma that separate each values into semi-colon, wherein those comma within parentheses ie. (39042, 39047) shouldn't be affected.
Already tried googling but cannot find anything.

Assuming your data is in A1
=SUBSTITUTE(A1, ")," , ");" )
I put spaces in for easier reading. Copy the formula down as far as you can go.
Alternatively use the built in search and replace function of excel. CNTRL + H.

Related

splitting underscores in Excel

I'm fairly new to Excel and need some assistance. I have a Column that has a list of files that look like:
12345_v1.0_TEST_Name [12345]_01.01.2022.html
45321_v55.9_Some Name Here [64398]_07.15.2018.html
56871_v14.2_Test[64398]_10.30.2019.html
Each file name can be different depending on what output is provided to me.
Note: There are other random files in the same format, however where it says Test_Name there could be an underscore and sometimes no underscore. Would like that to be ignored in the formula or vba. Files also can change but will be in the same format.
I need some help with a formula or vba that splits the underscores and outputs the data into their own cells:
Column C 12345
Column D v1.0
Column E TEST_Name [12345]
Column F 01.01.2022
Column G .html
Since there can be different file extensions however the format remains same, hence the above formula which i provided has been amended with some few tweaks so that it works for any file extensions,
FORMULA IN CELL C1
=IF(LEN($B1)-LEN(SUBSTITUTE($B1,"_",""))+1>4,
TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($B1,"."&TRIM(RIGHT(SUBSTITUTE(
SUBSTITUTE($B1,"."," ",LEN($B1)-LEN(SUBSTITUTE($B1,".","")))," ",REPT(" ",200)),100)),"_"&"."&
TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE($B1,"."," ",LEN($B1)-LEN(SUBSTITUTE($B1,".","")))," ",
REPT(" ",200)),100))),"_"," ",3),"_",REPT(" ",100)),COLUMN(A1)*99-98,100)),
TRIM(MID(SUBSTITUTE(SUBSTITUTE($B1,"."&TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(
$B1,"."," ",LEN($B1)-LEN(SUBSTITUTE($B1,".","")))," ",REPT(" ",200)),100)),"_"&"."&
TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE($B1,"."," ",LEN($B1)-LEN(SUBSTITUTE($B1,".","")))," ",
REPT(" ",200)),100))),"_",REPT(" ",100)),COLUMN(A1)*99-98,100)))
FILL DOWN & FILL ACROSS!!!
There are other random files in the same format.....Files also can change but will be in the same format.
So, assuming the files indeed will be in the same format, we can brake this query down into the following requirements:
Change the 1st and 2nd occurence and the very last of the underscore into anything to split on;
Change the dot before the file-extension into anything to split on under the assumption we don't know if this would be '.html' or any other extension.
Since you have Microsoft365 we can use dynamic arrays and some basic functions to retrieve what you want:
=LET(X,SEARCH("_??.??.????.",A1),Y,"</s><s>",TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(REPLACE(A1,X,12,Y&MID(A1,X+1,10)&Y),"_",Y,2),"_",Y,1)&"</s></t>","//s")))
To break this down a little bit:
SEARCH("_??.??.????.",A1) - This part will make sure that we find the position of the very last underscore upto the dot before the file extension assuming you don't have any other date in your filenames in this specific format;
SUBSTITUTE() - We can use this formula to specifically change the 1st and 2nd instances of the underscore to anything we can split on;
FILTERXML() - You may notice we used valid xml start/end-tags to split our data using this function.
TRANSPOSE() - This last function will now spill the returned array over the columns instead of rows.
Without LET():
=TRANSPOSE(FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(REPLACE(A1,SEARCH("_??.??.????.",A1),12,"</s><s>"&MID(A1,SEARCH("_??.??.????.",A1)+1,10)&"</s><s>"),"_","</s><s>",2),"_","</s><s>",1)&"</s></t>","//s"))
Is this what you are trying to achieve, although there might be more eloquent way to use a formula, and solve this, however you may try using this as well,
FORMULA USED IN CELL C1
=IF(LEN($B2)-LEN(SUBSTITUTE($B2,"_",""))+1>4,TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($B2,".html","_.html"),"_"," ",3),"_",REPT(" ",100)),COLUMN(A2)*99-98,100)),TRIM(MID(SUBSTITUTE(SUBSTITUTE($B2,".html","_.html"),"_",REPT(" ",100)),COLUMN(A2)*99-98,100)))
Fill Down & Fill Across !

Microsoft Excel Concatenation #VALUE! error

To try and make an everyday task for myself easier, I've been attempting to use:
=CONCATENATE(A1:A9)
Basically I have to grab groups of cells and wrap the text to fit in an attribute box elsewhere. I figured doing it right in Excel would be easier than writing something original with, say, Python, but I'm not having any luck. I get that vague #VALUE! error when entering this. Additionally, there shouldn't be any delimiter. The goal is to tie each cell end to end, wrapping it, without spaces, like I mentioned above.
For clarification, I'm using Excel 2016.
Does anybody have a remedy?
CONCATENATE(A1:A9) accomplishes nothing. It just returns A1:A9.
I assume you want this:
= CONCATENATE(A1,A2,A3,...A9)
Or:
= A1&A2&A3&...&A9
Possibly also TEXTJOIN if you have the right version of Excel.
If you have Excel 2016 or 365, use TEXTJOIN:
=TEXTJOIN(" ",TRUE, A1:A9)
The " " means that your values will be delimited by spaces (put a comma or dash or whatever you need in there); the TRUE means that it will not include empty cells (change it to FALSE if you want placeholders for those); A1:A9 is your range that will be concatenated.

Concatenate function in Excel 2010 to add single quotes and commas

I am working on a loaner laptop and have found that the concatenate function I have used to add single quotes and a comma to a column of text is no longer working. I need this to bring a series of IDs into a SQL query. The function I have used for years is =concatenate("'",A1,"',") to get a result of 'A1',. This is in Microsoft Excel 2010.
Try the following as an alternative to =concatenate():
="'"&A1&"',"
I've been using the above to do exactly what you're trying to accomplish.
Follow the below steps.
1- select all the rows.
2- right click and select format cells
3- select number tab
4- select custom in the left category tab and
5- under the type enter '#' (if column has hello after applying format it will turn into 'hello')
Use Excel Characters.
In your case it would be :
= concatenate(CHAR(39),A1,CHAR(39))
To get the result = 'A1'
similarly, you can include other special charterers as well. Like to include space you need to use CHAR(32).
Sadly textjoin() function is not in Excel 2010 but if someone is wondering how to concatenate several columns, wrapping the values in a single quote in the latest Excel versions just run this:
=TEXTJOIN(delimeter, ignore empty cells (true|false), usual range of cells)
I used something like this to create a sql script to insert values in a table:
="INSERT INTO my_table values ('" & TEXTJOIN("','", False, A2:Z2) & "')"
check the official docs for further details.
To enclose all specified cells in quotes, the following simple formulas may help you.
Method 1:
Use below formula into the blank cell:
=CHAR(34) & A1 & CHAR(34)
Considering the value that you want to enclose in quotes is present in A1 cell
Method 2:
To insert single quotes around the cell values, use this formula:
="'" & A1 & "'"
Simply put single quote inside double quotes. "'"

Removing a Line Feed substring without using vba

I am using a Vlookup to take the content of a cell in another sheet. The problem is that this cell has 2 lines, written by VBA, seperated by chr(10) or vbLF (equivalent of alt+enter to switch lines in a cell). I only want the first line. This is what I have right now (RechercheV is Vlookup in French):
=RECHERCHEV("btn_" & etape_doc;LangueEtapes!A:D;3;FAUX)
It returns "Transfert1Responsable:IC" (in the target cell, Transfert1 is on the first line, and Responsable:IC is on the next). I want to break at the line change and only retain "Transfert1".
Thanks a lot!
Turns out a line feed is called CHAR(10) in English and CAR(10) in French. So using this: http://www.gcflearnfree.org/excel-tips/how-to-use-excels-vlookup-function
I changed my formula to this:
= GAUCHE(RECHERCHEV("btn_" & etape_doc;LangueEtapes!A:D;3;FAUX); TROUVE(CAR(10); RECHERCHEV("btn_" & etape_doc;LangueEtapes!A:D;3;FAUX))-1)
And it worked perfectly!
Source for Char(10): http://blog.contextures.com/archives/2011/08/08/add-line-break-in-excel-formula/
EDIT: The whole goal of this was to add an IF statement that would change the text based on the language as chosen by the user. The language is chosen from a validation list in another sheet (French of English) and the VlookUp looks at column 3 for French version, and column 4 for English version. After adding the IF statement I ended up with this monster (This is aside the question, I'm posting in case anyone want to go further with their VlookUp functions):
=SI(Paramètres!cell_langue="FR"; GAUCHE(RECHERCHEV("btn_" & etape_doc;LangueEtapes!A:D;3;FAUX); TROUVE(CAR(10); RECHERCHEV("btn_" & etape_doc;LangueEtapes!A:D;3;FAUX))-1); GAUCHE(RECHERCHEV("btn_" & etape_doc;LangueEtapes!A:D;4;FAUX); TROUVE(CAR(10); RECHERCHEV("btn_" & etape_doc;LangueEtapes!A:D;4;FAUX))-1))

Combine several columns into one cell in Excel

I have a situation where I have 123 columns of data and out of those 123 colums, only up to 6 of them will be poplated with data. I need to collect all the fields that do have data and put them into one cell.
I found this article, How to merge rows in a column into one cell in excel?, on stackoverflow but it still is not quite what I am looking for and I could not get the =transpose solution to work as suggested at the bottom of the thread. I found a 3rd party solution that was a plugin for Excel but it is only for Windows and I have Office for Mac.
So I desperately need to know how to do this. I'am not showing 123 columns but I think you get the idea.
http://grab.by/BwDu
=concatenate(text,text,text...) is not an option because even if I wanted to put all 123 fields in here i am still faced with the problem of the formula putting in a space or comma in place of a blank field.
The ConcatenateRange function at the link you posted seems to accomplish what you want.
If you prefer a formula, this works for your example data:
=SUBSTITUTE(
TRIM(
B1&" "&C1&" "&D1&" "&E1&" "&F1&" "&G1&" "&H1&" "&I1&" "&J1&" "&
K1&" "&L1&" "&M1&" "&N1&" "&O1&" "&P1&" "&Q1&" "&R1&" "&S1
),
" ",
","
)
Output:
cat,bird,dog,mouse,horse,elephant,chimp,lion,sloth,zebra,geraf,snake,grasshopper
This formula concatenates the data with spaces. TRIM changes multiple spaces to single spaces, and SUBSTITUTE replaces all the spaces with commas.
To reach 123 columns, you'll simply need to continue adding cells.

Resources