+ Reply to Thread
Results 1 to 8 of 8

Substring extraction without "Text to Columns"

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Question Substring extraction without "Text to Columns"

    Hi all,
    I am unsure how to manipulate substrings without performing "text to columns".
    Background:
    Our sheet looks for and extracts data from a source based on unique identifiers. At times, the source will change the unique identifiers. Eg: v123456 may change to v654321. I have created some code that performs a cansim number validation check. If the number exists, continue with the update process. If it does not exist, the code will reference the title that corresponds to the cansim number. Eg: v654321 represents "Copper Prices" (the title). If the title is found from the source file, I want to update our cansim number to match the source cansim number. The problem is, the source cansim number is embedded in the source title. Eg: Title "Copper Prices [1003] (v654321)", which is located in one cell. I want to extract just the "v" series number (v654321) and not the rest. How can I extract just the "v" series?
    Hopefully I have described this well enough.

    Best Regards:
    Last edited by Mordred; 10-01-2010 at 06:14 PM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Substring extraction without "Text to Columns"

    Is the v-number always in brackets?

    If so try:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Substring extraction without "Text to Columns"

    Hi Andrew, thanks for your input. Yes, the v-numbers is always in brackets from the source. I tried what you suggested but it creates a compile error stating "A1" variable cannot be defined. Is your suggestion a function for the spreadsheet side of things? I'll be completely honest, I am not very well versed with the spreadsheet side, I've taken on Excel programmatically, not the other way around. Anyhow, here is the code I am trying to apply this to:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Substring extraction without "Text to Columns"

    If the number you want always has the ( and ) characters around it then it is pretty simple.

    If "Copper Prices [1003] (v654321)" is in B3 then the formula to extract stuff between ( and ) is:

    =MID(B3,FIND("(",B3)+1,FIND(")",B3) - FIND("(",B3)-1)

    Other guys like to replace all the stuff to the left of ( with "" and start from there.
    You will need to find the formula that you like the best.

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Substring extraction without "Text to Columns"

    I see the confused emoticon does not work when inside code tags.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Substring extraction without "Text to Columns"

    Please Login or Register  to view this content.



  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Substring extraction without "Text to Columns"

    Hi Mordred,
    You can extract the v654321 number using VBA string functions. There are a lot less of them than in Excel. Find the list at: http://www.techonthenet.com/excel/fo.../index_vba.php
    This site shows how to convert cell functions to VBA.

    If you need help extracting the string between ( and ) using vba please reply to this and I'll do it.

  8. #8
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Substring extraction without "Text to Columns"

    Thanks Marvin for the link, I used this and it works:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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