Concatenate and Trim question

bflan0524

Board Regular
Joined
Oct 7, 2016
Messages
192
Office Version
  1. 2010
hello if column A row 1 says RM1-CT and Column B says Joe Smith how can i get column C Row 1 to say RM1-CT-Smith
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
=a1& "-" & right(b1,len(b1)-find("*",substitute(b1," ","*",len(b1)-len(substitute(b1," ","")))))
 
Upvote 0
Hi,

Here's another way:


Book1
ABC
1RM1-CTJoe SmithRM1-CT-Smith
Sheet16
Cell Formulas
RangeFormula
C1=A1&"-"&MID(B1,FIND(" ",B1)+1,255)
 
Upvote 0
Hi,

Here's another way:

ABC
1RM1-CTJoe SmithRM1-CT-Smith

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet16

Worksheet Formulas
CellFormula
C1=A1&"-"&MID(B1,FIND(" ",B1)+1,255)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
hello,
i get a #VALUE error when i do this one
 
Upvote 0
I can't replicate your Error, you may have hidden characters in those cells, how are the values in A1 and B1 populated?
 
Last edited:
Upvote 0
so i had actually put columns A& B in my example for simplicity stake, in my workbook they are column G and N. here is the formula i put in, maybe i made a typo that i am not seeing. does this formula look right

=G2&"-"&MID(N2,FIND(" ",N2)+1,255)
 
Upvote 0
That formula looks fine and should work, it's a pretty simple formula.
Are the values in G2 and N2 manually entered, as a result of some formula, or imported from somewhere?
 
Upvote 0
actually i see the issue in column N the name i entered as follows for example Joe_Smith
how would i account for the _ between the names
lastly could you also break down for the me what the formula means/does so i fully understand it as opposed to just copying a formula

thanks for your time and help
 
Upvote 0
actually i see the issue in column N the name i entered as follows for example Joe_Smith
Is the separator between the first and last name always going to be an underbar character or will it sometimes be an underbar character and other times a space character between the first and last names?
 
Upvote 0
actually i see the issue in column N the name i entered as follows for example Joe_Smith
how would i account for the _ between the names
lastly could you also break down for the me what the formula means/does so i fully understand it as opposed to just copying a formula

thanks for your time and help

You never said anything about the "_" underscore, and why explain a formula that isn't working for you, let's get it working first, try this, it'll cover SPACE, UNDERSCORE, SPACE UNDERSCORE, UNDERSCORE SPACE, SPACE UNDERSCORE SPACE, UNDERSCORE SPACE UNDERSCORE:


Book1
ABC
1RM1-CTJoe SmithRM1-CT-Smith
2RM1-CTJoe_SmithRM1-CT-Smith
3RM1-CTJoe_ SmithRM1-CT-Smith
4RM1-CTJoe _SmithRM1-CT-Smith
5RM1-CTJoe _ SmithRM1-CT-Smith
6RM1-CTJoe_ _SmithRM1-CT-Smith
Sheet16
Cell Formulas
RangeFormula
C1=A1&"-"&TRIM(SUBSTITUTE(MID(B1,FIND(" ",SUBSTITUTE(B1&"_","_"," "))+1,255),"_",""))


If you don't need all those possibilities, let us know, we can make the formula simpler.
 
Upvote 0

Forum statistics

Threads
1,215,694
Messages
6,126,253
Members
449,305
Latest member
Dalyb2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top