Excel formula

Kazdima

Board Regular
Joined
Oct 15, 2010
Messages
226
Hello,<o:p></o:p>
<o:p> </o:p>
I need to build a formula, which can combine two data from Aand C into B.<o:p></o:p>
Data in C can be from 0(zero) to ABSD (four letters).<o:p></o:p>
You can see in B how the result should look like.<o:p></o:p>
Account (A)<o:p></o:p>
Combined GL (B)<o:p></o:p>
Cost_Center (C)<o:p></o:p>
01-001-1-000-0000 Legislative Grants<o:p></o:p>
01-001-1-000-0000-0 Legislative Grants<o:p></o:p>
0<o:p></o:p>
01-011-1-000-0062 Other Grants-Parents reac<o:p></o:p>
01-011-1-000-0062-STM Other Grants - Parents reac<o:p></o:p>
STM<o:p></o:p>
<tbody> </tbody>
<o:p> </o:p>
Thank you.<o:p></o:p>
 
Still I have two extra spaces between "-" and "0", and between "0" and "Legislative".
So, there should be no space between "0" and "-", and one space between "0" and "L"
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
'Still' ? What have you tried so far to remove them ? Did you try my suggestion(s) from the last post?

What do these return?
=CODE(LEFT(C1,1))
=CODE(MID(C1,2,1))

These should tell us what exactly those 2 characters are, if using TRIM didn't work then they are NOT spaces.
 
Upvote 0
When I used this formula: =REPLACE(A1,18,0,"-"&TRIM(C1))<o:p></o:p>
I got thisresult: 01-001-1-000-0000-0 Legislative Grants (Two spaces instead of onebetween “0” and “L”<o:p></o:p>
<o:p> </o:p>
When IUSED THIS FORMULA: =REPLACE(A1,18,0,"-"&RIGHT(C1,LEN(C1)-2))<o:p></o:p>
<o:p> </o:p>
01-001-1-000-0000-0 Legislative Grants (Space between “-“and “0” and the same as above<o:p></o:p>
<o:p> </o:p>
Yourlast message I used as it is:<o:p></o:p>
Code(left(c1,1)) returned number 32<o:p></o:p>
Code(mid(c1,2,1)) returned number 109<o:p></o:p>
 
Upvote 0
It's going to be difficult to figure it out without actually seeing the real underlying data (in Excel, not written in a forum)
Can you post a sample file to a file sharing site (desensitize your data).

Maybe explaining what the basic formula is actually doing will help you sort it out..

=REPLACE(A1,18,0,"-"&C1)

The & symbol is short for the concatenate function. It joins 2 text strings together into 1.
so "-"&C1 is joining a hyphen with whatever is in C1.
If C1 is 0, then "-"&C1 = "-0"

=REPLACE(A1,18,0,"-0")

Replace is INSERTING the string "-0" between the 18th and 19th characters in A1.

Hope that helps.
 
Upvote 0
Thank you, explanation helps-:)

But, for now the best result gives this one.

This formula: =REPLACE(A1,18,0,"-"&TRIM(C1))
ONLY we need to reduce one more space between “0” and “L”
I got this result: 01-001-1-000-0000-0 Legislative Grants (Two spaces instead of one between “0” and “L”
 
Upvote 0
I found solution. Just was playing with numbers-:) Instead of "0", should be 1
REPLACE(A1,18,1,"-"&TRIM(C1))

Thank you. Without your help I would not do it.

<tbody>
</tbody><colgroup><col></colgroup>
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,262
Members
449,075
Latest member
staticfluids

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