Page 1
Page 1
Started By
Message

Yet another excel question, something similar to left/right functions

Posted on 3/27/15 at 3:33 pm
Posted by TU Rob
Birmingham
Member since Nov 2008
12729 posts
Posted on 3/27/15 at 3:33 pm
I have a pretty massive spreadsheet and it has a listing of cost centers in it, by loan account number. About 4,200 of them, of which there are maybe 300 different centers. We are going through a big naming convention change, and I have identified which ones need to be renamed, and which ones need to have a new name altogether. Each cell with a cost center has some descriptions, like city name, area, etc. As well as a 10 digit number in parentheses at the end of it. I have a concatenate formula set up, but what I need to do is insert the new naming convention between the city/area name and the 10 digit number.

So for example, Birmingham would be:
Birmingham: XXXXX (1234567890) and I need to have it look like:
Birmingham: XXXXX - XYZ (1234567890).
I have all of the codes where the XYZ will go identified as well.

I have used a right formula to extract the 10 digit number, but I need a way to get just the characters in the cell prior to that number to show up. Only they are all city/area names so it isn't a standard number of characters so I can't use a simple left formula.

Any ideas?
Posted by Spock's Eyebrow
Member since May 2012
12300 posts
Posted on 3/27/15 at 3:44 pm to
quote:

So for example, Birmingham would be:
Birmingham: XXXXX (1234567890) and I need to have it look like:
Birmingham: XXXXX - XYZ (1234567890).

I have used a right formula to extract the 10 digit number, but I need a way to get just the characters in the cell prior to that number to show up. Only they are all city/area names so it isn't a standard number of characters so I can't use a simple left formula.


If the colon consistently follows the city name and doesn't occur within city names, FIND will give its position, and then you can use LEFT.

Posted by TU Rob
Birmingham
Member since Nov 2008
12729 posts
Posted on 3/27/15 at 3:50 pm to
quote:

If the colon consistently follows the city name and doesn't occur within city names, FIND will give its position, and then you can use LEFT.


It usually does, but where I put XXXXX are different company names. Some are abbreviations, others are spelled out. I basically need to keep everything that is prior to the Parentheses, so that is where I need the formula to focus on.
Posted by TU Rob
Birmingham
Member since Nov 2008
12729 posts
Posted on 3/27/15 at 3:57 pm to
Played around with some find and replace options. I did find: (* and in the replace field hit delete and then replace all and it worked.
Posted by Spock's Eyebrow
Member since May 2012
12300 posts
Posted on 3/27/15 at 4:01 pm to
Then search for the opening parentheses. You have to identify a consistent pattern, and if it's as simple as "everything in front of a delimiter (e.g. colon or opening paren)", you can use the built-in Excel functions to extract the prefix string. If it's more complicated, and the simple wildcards available with SEARCH don't cut it, you may need to delve into regular expressions, which Excel does support through macros and add-ins. Google /Excel regex/ for more on that.
Posted by CubsFanBudMan
Member since Jul 2008
5060 posts
Posted on 3/30/15 at 10:45 am to
Assuming ( is only used once, this formula should work based on the old name in cell A1, the addition needed in cell B1:

=LEFT(A1,FIND("(",A1)-1)&"- "&B1&" "&MID(A1,FIND("(",A1),99)
first pageprev pagePage 1 of 1Next pagelast page
refresh

Back to top
logoFollow TigerDroppings for LSU Football News
Follow us on Twitter, Facebook and Instagram to get the latest updates on LSU Football and Recruiting.

FacebookTwitterInstagram