Consulting

Results 1 to 6 of 6

Thread: Get index using RegExp

  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Get index using RegExp

    I've created some code to display selected photographs based on their index number in a report. The way the report is constructed lists the photo refernces within brackets, which may be in any of the following forms. The report is 300+ pages with 5,500 photo references, so a bit of a problem to "regularise".
    (X078)
    (A078/A079/A080)
    (X078, X079)
    (AB078 - AB083)
    I would like to "extract" the reference number by running the macro when the insertion point is within the reference.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    A question. If the Selection is in: (AB078 - AB083) , which number would be extracted? All of them?

  3. #3
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Gerry,
    Just the number with the insert. My userform will have Next and Previous buttons to deal with this situation.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Expert
    Joined
    Jul 2004
    Location
    Wilmington, DE
    Posts
    600
    Location
    Sorry Malcolm, it's still not clear
    Regards,

    Patrick

    I wept for myself because I had no PivotTable.

    Then I met a man who had no AutoFilter.

    Microsoft MVP for Excel, 2007 & 2008

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Patrick,
    Here's a small sample with the userform as WIP. I'm looking to initialise the Userform with the reference containing the insertion point.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    OK, I've finally got my brain in gear. Much simpler than I was thinking!
    [VBA]
    Sub Shows()
    UserForm2.Show False
    UserForm2.TextBox1 = Selection.Words(1)
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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