Concatenate function in Excel 2010 to add single quotes and commas - excel

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. "'"

Related

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.

Excel - Find and replace those comma not within parenthesis

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.

How to reference a cell in a excel hyperlink

This is what I have tried
=HYPERLINK("#"+M4+"!A1","Go To Go To Store")
The first section does not add the cell value to the other parts of the string.
It outputs "#"+"Text"+"!A1" instead of #Text!A1
If I am far off the overall objective is to get a list of hyperlinks to every spreadsheet into a drop down list please can you advise on that
You need using text concatenation. But + is only add up operator in Excel. Text concatenation is &.
So
=HYPERLINK("#"&M4&"!A1","Go To Go To Store")
But if the single sheet names in M4 can be multiple words delimited with spaces, then they must be enclosed within single quotes. So
=HYPERLINK("#'"&M4&"'!A1","Go To Go To Store")
will be more flexible.

Having an issue with excel "text to columns" feature - need to remove space

I have 100's of rows of data, each row containing a list of multiple items separated by comma. for example:
a fox, a frog, a dog, candy,
tyler, daren, hogge, laura,
cat in the hat, remembering your favorite day, having a fun time
etc
as you can see, its not a simple "lastname, firstname" separation.
the issue im having is when i use text to columns, i can easily separate by comma, but im then left with a space before every second item in the list. I need to remove the space after each comma (but not EVERY space after each word!)
I cant just select "comma" and "space" in the delimiters option, because then it removes EVERY space between words (eg 'havingafuntime') when i only want to remove THE ONE space after the comma.
I know i can use "trim" - but im wondering if theres a way to remove the space WHILE SEPARATING THE TEXT TO COLUMNS, all in one swoop.
When working "normal" with excel you can simply left out any formulas for this case.
Instead of the =SUBSTITUTE(A1,", ",",") you can simply select the range you want to be corrected (like the whole A:A column) and press Ctrl+H (replace). Set "Find What" to ", " and "replace with" to "," (without the "). Hit replace all the to do it for the whole selection (non selected cells won't be replaced).
The build-in "Text to columns" can not be manipulated in a way to do it in one step.
EDIT:
Doing it as a one-click-macro just this 4 lines should do what you desire:
Sub text2cols()
Selection.Replace ", ", ","
Selection.TextToColumns Selection.Resize(1, 1), 1, , , , , True
End Sub
Just select the range you want to seperate and run the macro ;)
in the cell adjacent to the start of the column you are going to convert using text to columns, enter the following formula and copy down.
=substitute(A1,", ",",")
This will remove the space after every ,
Then copy and paste as value the resulting column.
Then perform your Text to Columns operation using , as you delimiter.
Another option would be to use Power Query.
Depending on your version of excel you should be able to download an install Power Query by googling "Download Power query for Excel 20X"
click in your data set
On Power query tab you will see "From Table" (in excel 2016 its already in data tab, you do not have to download it)
choose if your data has header or not
Go to Transform
Under Split column choose by delimiter
Choose comma
Under Format you will see Trim
Go to Home tab choose close and load
and you're done
I know this is an old post, but I found this doing a google search because I had the same problem as the OP. However, upon reading some of the suggestions it came to me that I can use the Find & Replace feature. I selected the column in question and did the following:
Find what: ", " (without quotes - used to show space)
Replace with: , (no space)
Essentially this made the list go from: a fox, a frog, a dog, candy, tyler, daren, hogge, laura, cat in the hat, remembering your favorite day, having a fun time
And changed it into this: a fox,a frog,a dog,candy,tyler,daren,hogge,laura,cat in the hat,remembering your favorite day,having a fun time
Then I just used the Text To Column function delimited by comma and it worked beautifully.
I hope this helps someone else out.

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))

Resources