[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to combine text in Excel

Posted on 2014-12-16
5
Medium Priority
?
359 Views
Last Modified: 2014-12-17
In the attached screenshot, you see my attempts at combining the text assembled in column "E" - the fifth column over from the left.

What I want to do is craft an "forumula" that combines all of the text in column E so when I combine it with "CREATE TABLE 'volte7' (..." I'll have "CREATE TABLE 'volte7' ('EndDate' DATE NOT NULL, 'Num Days' varchar(20) DEFAULT NULL, 'Area' varchar(150) DEFAULT NULL...

...and so on.

You can see where I started to write out in column G "=E4&""&E5&" and I stopped because I was wondering if there was a quicker way to do it.

Thoughts?

screenshot
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 19

Expert Comment

by:Montoya
ID: 40503175
short of using CONCATENATE  e.g. =CONCATENATE("CREATE TABLE ",A2&" ",A3&" ",A4)

you could write VBA that iterates through each row and does the same thing. Were you trying to stay away from VBA?
0
 
LVL 18

Accepted Solution

by:
Simon earned 2000 total points
ID: 40503176
I would do that by starting with a single value =RC-1 (i.e. the cell to the left)
then for the next row down in the column:
=R-1C &  RC-1
and drag that down.

The bottom row then contains the entire formula.

Sorry to express that in normal notation
start with
=E5 (in cell F5)
=F5 & "," & E6 (in cell F6)
etc
0
 

Author Comment

by:brucegust
ID: 40503200
Simon, that did it!

Thanks!
0
 
LVL 81

Expert Comment

by:byundt
ID: 40503209
Consider using a user-defined function (UDF) to build your string with a worksheet formula like:
=StringBuilder(E4:E28)

To create a UDF:
1. ALT + F11 to open the VBA Editor
2. Insert...Module to create a blank module sheeet
3. Paste the following code there:
Function StringBuilder(rg As Range) As String
Dim s As String
Dim cel As Range
For Each cel In rg.Cells
    If cel.Value <> "" Then s = s & cel.Value
Next
StringBuilder = s
End Function

Open in new window

4. ALT + F11 to return to the worksheet userinterface
5. Use the function wizard (fx icon to left of formula bar) the first time you need to use the new function. It will be found under category "User defined".
StringBuilderQ28582044.xlsm
0
 
LVL 18

Expert Comment

by:Simon
ID: 40503217
Glad to help. If you do EXACTLY the same thing a lot, it would be worth having a UDF for it, but for one-off quickies, I find formulae like the ones I posted the fastest way to achieve the desired result.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question