+ Reply to Thread
Results 1 to 24 of 24

Formula that removes chars in parenthesis regardless of length.

  1. #1
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Formula that removes chars in parenthesis regardless of length.

    Please Login or Register  to view this content.
    i am using this formula to flip first and last name, remove the comma, and also remove (NonEmp) (hence the -8 bolded in the second FIND function.

    So if Jones, Jack R (NonEmp) were in A13, it would show like this Jack R Jones (NonEmp)
    or Jones, John would show simply as John Jones

    The problem is, I want to plan ahead and have it remove the Parenthesis and it's contents regardless of length. So if it is entered (Non Emp) it will still remove.

    I tried this to no avail... Bolded is what changed.

    Please Login or Register  to view this content.
    any suggestions?
    Last edited by Jhail83; 08-14-2013 at 01:10 PM.

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Formula that removes chars in parenthesis regardless of length.

    Can you give a sample of what a given cell looks like now, and how you want it to look when you're done?

    -edit: thanks for the update
    Last edited by daffodil11; 08-14-2013 at 01:17 PM.

  3. #3
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Formula that removes chars in parenthesis regardless of length.

    Orignal = Desired
    1.Jones, Jack R (NonEmp) = Jack R Jones (NonEmp)
    2.Jones, Jim (Non Emp) = Jim Jones (NonEmp)
    3.Jones, John = John Jones

    Right now "2." shows up as "Jim ( Jones (NonEmp)"
    Last edited by Jhail83; 08-14-2013 at 01:27 PM.

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Formula that removes chars in parenthesis regardless of length.

    Okay, got it. Let me fire up the ol' noggin.

  5. #5
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: Formula that removes chars in parenthesis regardless of length.

    Try this... I'm assuming (NonEmp) is the only "extra" info in the parenthesis...

    =RIGHT(SUBSTITUTE(A1," (NonEmp)",""),LEN(SUBSTITUTE(A1," (NonEmp)",""))-FIND(",",SUBSTITUTE(A1," (NonEmp)",""))-1)&" "&LEFT(SUBSTITUTE(A1," (NonEmp)",""),FIND(",",SUBSTITUTE(A1," (NonEmp)",""))-1)

    re-post: sorry daffodil for stepping on your toes...

  6. #6
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Formula that removes chars in parenthesis regardless of length.

    That's fine. Sometimes it takes a group effort.

    I have a presentation I should be working on but I needed a fun diversion.


    I'm stuck on removing the space. Maybe an IF?

  7. #7
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: Formula that removes chars in parenthesis regardless of length.

    Here's a shorter version...

    =SUBSTITUTE(RIGHT(A3,LEN(A3)-FIND(",",A3)-1)&" "&LEFT(A3,FIND(",",A3)-1)," (NonEmp)","")

  8. #8
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Formula that removes chars in parenthesis regardless of length.

    Quote Originally Posted by djapigo View Post
    Here's a shorter version...

    =SUBSTITUTE(RIGHT(A3,LEN(A3)-FIND(",",A3)-1)&" "&LEFT(A3,FIND(",",A3)-1)," (NonEmp)","")
    Hmm...That would make "Jones, Jack R (Non Emp)" show as "Jack R (Non Emp) Jones"
    I am striving to make it show as "Jack R Jones (NonEmp)"

    Meaning, the original data could have (NonEmp) or (Non Emp) at the end, or it could just have Last Name, First Name MI.

    So it either has Parenthesis around something at the end or nothing at all but the name.

    Definitely appreciate the effort though!
    Last edited by Jhail83; 08-14-2013 at 01:47 PM.

  9. #9
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: Formula that removes chars in parenthesis regardless of length.

    Hi Jhail,

    Is it (Non Emp) or (NonEmp)

  10. #10
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Formula that removes chars in parenthesis regardless of length.

    djapigo
    Could be either. Which is why I was hoping I could just count the characters between "(" and ")" and add 2 to that count and replace the 8 in my original formula with that. So it would remove the Parenthesis and anything between them, regardless of length.

  11. #11
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: Formula that removes chars in parenthesis regardless of length.

    It's far from pretty, but I have this... (sorry, I'm really stubborn about the parenthesis)...

    =IF(ISNUMBER(SEARCH("NonEmp",A1)),SUBSTITUTE(RIGHT(A1,LEN(A1)-FIND(",",A1)-1)&" "&LEFT(A1,FIND(",",A1)-1)," (NonEmp)","")&" (NonEmp)",IF(ISNUMBER(SEARCH("Non Emp",A1)),SUBSTITUTE(RIGHT(A1,LEN(A1)-FIND(",",A1)-1)&" "&LEFT(A1,FIND(",",A1)-1)," (Non Emp)","")&" (Non Emp)",RIGHT(A1,LEN(A1)-FIND(",",A1)-1)&" "&LEFT(A1,FIND(",",A1)-1)))

  12. #12
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Formula that removes chars in parenthesis regardless of length.

    djapigo

    Wow!
    One thing though, could it be altered to change (Non Emp) to (NonEmp) or vice versa (they just have to all be the same)?

    Right now, for instance, "Jones, Jack R (Non Emp)" changes to "Jack R Jones (Non Emp)" and "Jones, John L (NonEmp)" changes to John L Jones (NonEmp).

    But If I have instances of both formats in the data, it won't be uniform. So I'd like "Jones, Jack R (Non Emp)" to display as "Jack R Jones (NonEmp)" if at all possible!

    Thanks so much for the work you have done to help already though! I appreciate it.

  13. #13
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Formula that removes chars in parenthesis regardless of length.

    Please Login or Register  to view this content.
    Really, I think the best solution for my problem, is to have a function count the characters between "(" and ")" and add 2 to it.

    just not sure what that would be.

    then I can replace -FIND(",",A13)-8 with that function.


    Edit
    I am confused, because =LEN(A13)-FIND("(",A13)+1 returns 8 when it is used alone, if A13 contains "Jones, Kristina (NonEmp)"

    It cuts off the name though.

    So anything longer than the number of characters after "(" gets cut off.

    Jones, Kristina (NonEmp) Becomes Kristin Jones (NonEmp)
    but Jones, Kristina (Non Emp) becomes Kristina Jones (NonEmp)

    Edit: I figured it out.


    Please Login or Register  to view this content.
    I needed to change "MID(A13,FIND(",",A13)+1" to "MID(A13,FIND(",",A13)+2" to account for the space after the comma.
    Though some records might not have a space after the comma... Just the ones I am testing do.

    so if a name is like this "Jones,James L(NonEmp)" It wouldn't display right..
    Last edited by Jhail83; 08-14-2013 at 04:11 PM.

  14. #14
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Formula that removes chars in parenthesis regardless of length.

    I guess my new question is, is there a way to modify my formula to account for both the space after the comma and it not having a space, as ill chop off letters if I do not account for that.


    Please Login or Register  to view this content.
    FIND(",",A13)+2 Is the part I am worried about. "+2" assumes a space. +1 would assume no space.

    SO maybe something like this


    Please Login or Register  to view this content.
    However, I messed that up somehow because it returns #VALUE!.
    Last edited by Jhail83; 08-14-2013 at 04:56 PM.

  15. #15
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Formula that removes chars in parenthesis regardless of length.

    This is getting trickier and trickier.

    Just so we are clear, we need to accommodate:

    Jones, John -> John Jones
    Jones, John R -> John R Jones

    Jones, John (NonEmp) -> John Jones (NonEmp)
    Jones, John R (NonEmp) -> John R Jones (NonEmp)

    Jones, John (Non Emp) -> John Jones (NonEmp)
    Jones, John R (Non Emp) -> John R Jones (NonEmp)

    I piece together the logic separately and I want to be able to account for each variance. Is it possible someone will have more than one middle initial, or just an initial for first name?

    e.g.
    Simmons, J. K.
    Tolkien, John R. R.

  16. #16
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: Formula that removes chars in parenthesis regardless of length.

    Here's a simple change to get what you want... notice that I simple "add" that text back...

    =IF(ISNUMBER(SEARCH("NonEmp",A1)),SUBSTITUTE(RIGHT(A1,LEN(A1)-FIND(",",A1)-1)&" "&LEFT(A1,FIND(",",A1)-1)," (NonEmp)","")&" (NonEmp)",IF(ISNUMBER(SEARCH("Non Emp",A1)),SUBSTITUTE(RIGHT(A1,LEN(A1)-FIND(",",A1)-1)&" "&LEFT(A1,FIND(",",A1)-1)," (Non Emp)","")&" (NonEmp)",RIGHT(A1,LEN(A1)-FIND(",",A1)-1)&" "&LEFT(A1,FIND(",",A1)-1)))

  17. #17
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Formula that removes chars in parenthesis regardless of length.

    I tried my best to break it and I could not. That is amazing.

  18. #18
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Formula that removes chars in parenthesis regardless of length.

    A little late to the party, but...
    =IFERROR(MID(A1,FIND(" ",A1)+1,FIND(" (",A1)-FIND(" ",A1))&LEFT(A1,FIND(",",A1)-1)&" (NonEmp)",MID(A1,FIND(",",A1)+2,LEN(A1))&" "&LEFT(A1,FIND(",",A1)-1))
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  19. #19
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Formula that removes chars in parenthesis regardless of length.

    And this one takes care of the case when there is no space between the comma and the name:
    =IFERROR(TRIM(MID(A1,FIND(",",A1)+1,FIND(" (",A1)-FIND(",",A1)))&" "&LEFT(A1,FIND(",",A1)-1)&" (NonEmp)",TRIM(MID(A1,FIND(",",A1)+1,LEN(A1)))&" "&LEFT(A1,FIND(",",A1)-1))

    Also noticed it handles cases like:
    Jones Jr., Jack (NonEmp)
    Last edited by Pauleyb; 08-15-2013 at 11:25 AM.

  20. #20
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Formula that removes chars in parenthesis regardless of length.

    Thanks Pauley! Anyway you can get that to handle if there is no space between the name and Parenthesis?

    Like, Jones,Jack R(NonEmp)?

    if not it's fine, I really appreciate the help!

  21. #21
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Formula that removes chars in parenthesis regardless of length.

    Probably easier for you to just do a find and replace of your input text for "(" and replace with " (". The above formula should handle the extra space if added.

  22. #22
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Formula that removes chars in parenthesis regardless of length.

    True. I was just hoping to have it all in one formula so others could use it easily.

    And yes, it does handle the extra space.

    Thanks so much!

  23. #23
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Formula that removes chars in parenthesis regardless of length.

    This looks like it works:
    =IFERROR(TRIM(MID(A1,FIND(",",A1)+1,FIND("(",A1)-FIND(",",A1)-1))&" "&LEFT(A1,FIND(",",A1)-1)&" (NonEmp)",TRIM(MID(A1,FIND(",",A1)+1,LEN(A1)))&" "&LEFT(A1,FIND(",",A1)-1))

  24. #24
    Registered User
    Join Date
    07-18-2013
    Location
    Cincinnati
    MS-Off Ver
    2010
    Posts
    35

    Re: Formula that removes chars in parenthesis regardless of length.

    Thanks Pauley and everyone!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 07-21-2013, 06:57 AM
  2. Series in parenthesis of formula
    By andersb in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-12-2011, 04:41 AM
  3. Macro Removes Formula
    By Althas in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-21-2008, 10:25 AM
  4. formula for parenthesis round negative money values in excel
    By jeff in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-14-2006, 02:45 AM
  5. [SOLVED] Formula Split or parenthesis problem?
    By nastech in forum Excel General
    Replies: 0
    Last Post: 01-15-2006, 09:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1