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>
[TABLE="class: MsoNormalTable, width: 476"]
<tbody>[TR]
[TD="width: 350, bgcolor: transparent"] Account (A)<o:p></o:p>
[/TD]
[TD="width: 363, bgcolor: transparent"] Combined GL (B)<o:p></o:p>
[/TD]
[TD="width: 80, bgcolor: transparent"] Cost_Center (C)<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 350, bgcolor: transparent"] 01-001-1-000-0000 Legislative Grants<o:p></o:p>
[/TD]
[TD="width: 363, bgcolor: transparent"] 01-001-1-000-0000-0 Legislative Grants<o:p></o:p>
[/TD]
[TD="width: 80, bgcolor: transparent"] 0<o:p></o:p>
[/TD]
[/TR]
[TR]
[TD="width: 350, bgcolor: transparent"] 01-011-1-000-0062 Other Grants-Parents reac<o:p></o:p>
[/TD]
[TD="width: 363, bgcolor: transparent"] 01-011-1-000-0062-STM Other Grants - Parents reac<o:p></o:p>
[/TD]
[TD="width: 80, bgcolor: transparent"] STM<o:p></o:p>
[/TD]
[/TR]
</tbody>[/TABLE]
<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

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
'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
[TABLE="width: 354"]
<tbody>[TR]
[TD]REPLACE(A1,18,1,"-"&TRIM(C1))

Thank you. Without your help I would not do it.[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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