+ Reply to Thread
Results 1 to 5 of 5

Return Regular Expression match to array

  1. #1
    Registered User
    Join Date
    01-12-2021
    Location
    Canada
    MS-Off Ver
    365
    Posts
    9

    Return Regular Expression match to array

    Good afternoon

    I am trying to extract key information from a large data set. The data is in string format and a regular expression will pull the required data quickly.

    The sub routine works excellent when I simply print it to the immediate window.
    However, I would like to return the match to an array and then eventually to a range on a worksheet.


    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,761

    Re: Return Regular Expression match to array

    Quote Originally Posted by clams View Post
    Please Login or Register  to view this content.

    Please explain what "doesn't work" means.
    • Does the code run?
    • Does it run but do nothing?
    • Does it produce error messages? If so, what do the messages say?
    • Does it produce unexpected/wrong results? If so, how do the results differ from what you expect?
    • Does it hang?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    01-12-2021
    Location
    Canada
    MS-Off Ver
    365
    Posts
    9

    Re: Return Regular Expression match to array

    Hi 6StringJazzer,

    Thank you for responding. It does run but throws the following error message at the line you quoted.

    Run-time error '9':
    Subscript out of range

    I've checked that the destArray is properly sized. I don't understand how the MatchCollection works so I think that's where I am making a mistake. If I comment the line out, the script prints all of the RegEx matches on to the immediate window, as expected. I would like the script to take the RegEx match and put it in the appropriate location of the destArray

    Thanks again for helping me clarify the issue.

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

    Re: Return Regular Expression match to array

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-12-2021
    Location
    Canada
    MS-Off Ver
    365
    Posts
    9

    Re: Return Regular Expression match to array

    Thank you! That was the issue!

    appreciate the time you took to review the code. Having a working regular expression script will save me huge amounts of time in the future.

    I've marked the thread as solved.

+ 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] Help with VBA Regular Expression
    By noboffinme in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-13-2019, 12:16 AM
  2. Regular Expression to Return "True" or False" if a word is found
    By wwconslt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2017, 09:54 PM
  3. Regular Expression Help
    By wwconslt in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-18-2017, 10:33 PM
  4. [SOLVED] Regular expression
    By chief_abound in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-10-2015, 10:59 PM
  5. Regular expression
    By Gourav in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2014, 03:23 PM
  6. [SOLVED] Regular Expression
    By Kvramana in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2013, 05:32 AM
  7. [SOLVED] How to return the row # of an expression in specific array of cell
    By Rado in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-27-2006, 12:00 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