+ Reply to Thread
Results 1 to 8 of 8

How can I trim strings with re-occurring pattern to a defined string

  1. #1
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    How can I trim strings with re-occurring pattern to a defined string

    I have the following type of strings: (3 examples)

    BMC Nephrology (2015) 16:1 Article Number: 38. Date of Publication: 1 Dec 2015
    Toxicology (2015) 333 (89-99). Date of Publication: 3 Jul 2015
    Clinical Chemistry and Laboratory Medicine (2015) 53 SUPPL. 1 (S1043). Date of Publication: July 2015

    I want to reduce them to the following:

    BMC Nephrology
    Toxicology
    Clinical Chemistry and Laboratory Medicine

    How can I do this in a VBA?

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: How can I trim strings with re-occurring pattern to a defined string

    You can do this using regular Excel Functions aswell?

    Do you strictly want VBA?

    Assuming your data is starting from A1, put this in B1 and drag down as required..

    =LEFT(A1,FIND("(",A1)-2)
    Cheers!
    Deep Dave

  3. #3
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: How can I trim strings with re-occurring pattern to a defined string

    If you want to use VBA, you can use a UDF -

    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: How can I trim strings with re-occurring pattern to a defined string

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: How can I trim strings with re-occurring pattern to a defined string

    Jindon, great! That simple one liner does the job. One question. What is the function of the "2"?

    NeedForExcel, thanks for the solution. It's another way of doing it. But not as simple as jindon's one liner. Never the less I will keep it in mind.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: How can I trim strings with re-occurring pattern to a defined string

    It's a constant for LookAt argument, 1 for xlWhole, 2 for xlPart.

  7. #7
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: How can I trim strings with re-occurring pattern to a defined string

    I see. I understand. Thanks for clarifying.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: How can I trim strings with re-occurring pattern to a defined string

    You are welcome and thanks for the rep.

+ 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. [SOLVED] Find Most Common Occurring String Based on Lookup Value
    By kolor in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-11-2013, 09:17 PM
  2. Find most frequently occurring text string in in a VISIBLE range of cells
    By Odlanier in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-01-2013, 05:27 PM
  3. Using the .Pattern Method for identifying Strings
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-13-2013, 07:20 PM
  4. [SOLVED] Run Time 1004 - App Defined or Object defined error with String defined path structure
    By sarails in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-11-2012, 09:38 PM
  5. Replies: 5
    Last Post: 08-23-2010, 07:05 AM

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