+ Reply to Thread
Results 1 to 4 of 4

Extracting sub-string from excel column before performing match with another column (VBA)

  1. #1
    Registered User
    Join Date
    07-16-2020
    Location
    Derby, England
    MS-Off Ver
    Office 365
    Posts
    1

    Extracting sub-string from excel column before performing match with another column (VBA)

    I am fairly new to VBA and have been working on a task to automate a section of project report using VBA. The ultimate aim is to update the status of each test step in an MS Word Table with the latest test results. I have a working subroutine that imports the word tables to an excel worksheet (sheet 2). Sheet 1 already contains an excel table with the latest test results. My plan is to match items in the two sheets using the common identifier "TP_ID", however the appropriate column in the imported word table also contains a section number that is stopping any matches being found (see images below to see format of each sheet ID column).

    TP_ID.PNG
    Section_TP_ID_2.PNG


    I would like to find a way to either extract the TP_ID substring from the word table column and then perform a match routine. Below is the code I have so far. You can see the crucial step that I am missing marked by '????'

    Once matching is of all 2000 odd test steps is complete I then want to update column D of the imported word table on sheet 2 with the latest test results contained within column G of sheet 1. I believe my code reflects this, however I cannot test due to the fact that no matches can be found without the step that extracts TP_ID from the combined section number and TP_ID string.


    code_2.PNG

    I am aware of the RIGHT, LEFT and MID, routines but I have not found a way to use these because the length of the section number varies.


    Any assistance would be greatly appreciated

  2. #2
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,147

    Re: Extracting sub-string from excel column before performing match with another column (V

    Maybe like this;

    Please Login or Register  to view this content.

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

    Re: Extracting sub-string from excel column before performing match with another column (V

    Quote Originally Posted by javatyphoon View Post
    I am aware of the RIGHT, LEFT and MID, routines but I have not found a way to use these because the length of the section number varies.
    e.g
    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Extracting sub-string from excel column before performing match with another column (V

    Assuming you ID numbers (after the dash) are always 5 digits (could have non-digits in there as well) long, which appears to be the case given your examples, then this code will work...
    Please Login or Register  to view this content.
    Note: This code will work for the ID's that stand alone as well
    Please Login or Register  to view this content.
    Last edited by Rick Rothstein; 07-16-2020 at 10:03 AM.

+ 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: 05-14-2020, 02:47 PM
  2. [SOLVED] Formula or Macro, match string,from 1 cell to a column,String use dash
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-07-2013, 06:03 PM
  3. [SOLVED] Search Column A and B for string match and return value of column C
    By RichTea88 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-18-2013, 10:02 AM
  4. [SOLVED] Help: extracting text from column if two other columns match
    By rivendale34 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-19-2013, 04:42 PM
  5. Match string in one column, return value in same row, skip rows that down't match
    By anilsen0711 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2013, 05:35 AM
  6. [SOLVED] Extracting specific part of the text string to another column
    By ssanjju in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 01-20-2013, 07:20 PM
  7. Compare a string in two columns, if match then append string from third column
    By Londonderry in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-22-2007, 03:41 PM

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