+ Reply to Thread
Results 1 to 3 of 3

Parse String and Fill list box with Each Found Sub String

  1. #1
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Parse String and Fill list box with Each Found Sub String

    Hi all,

    I'm currently trying find a solution which will parse from a string
    each unique set of sub-strings:
    beginning with: '"EMTag_" & UCase(Excel.Application.UserName) & ">"
    and
    Ending with : "<EMTag"

    UCase(Excel.Application.UserName) will a variable within the substrings.


    '"EMTag_" & UCase(Excel.Application.UserName) & ">" & "ANT" & "<EMTag"
    I thought of possibly using regular expressions in some such statement.

    With CreateObject("vbscript.regexp")
    '"EMTag_" & UCase(Excel.Application.UserName) & ">" & "ANT" & "<EMTag"
    .Pattern = "[EMTag_] * [<EMTag] ' <don't know if this is correct

    .IgnoreCase = False
    .Global = True
    lCount = .Execute(S).Count
    'If lCount Then StoreIt2 = Trim(.Replace(Me.Txt_DESCRIPTION.Text, " " & "$1"))
    'MsgBox .Text
    ' If lCount Then StoreIt2 = Trim(.Replace(.Text, " " & "$1"))

    ' "$1" = Ucase(Left("$1", 1)) & mid("$1",Len($1)-1)

    If lCount Then
    For i = 1 To lCount
    UserForm17.ListBox1.AddItem (.Execute(S)) < loop for each Lcount and add each unique expression to the listbox.
    Next i
    End If
    Not sure if it's possible to something like

    Please Login or Register  to view this content.

    I really hope this make sense as to what I'd like to accomplish.

    Any help is greatly appreciated.
    Last edited by bdb1974; 06-21-2011 at 05:56 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Parse String and Fill list box with Each Found Sub String

    bdb1974,

    Are you trying to find out what is between the ">" and "<" such that in this case, it should return "ANT" ?
    "EMTag_" & UCase(Excel.Application.UserName) & ">" & "ANT" & "<EMTag"

    In which case you could use the following:
    Please Login or Register  to view this content.


    Hope that helps,
    ~tigeravatar

  3. #3
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Parse String and Fill list box with Each Found Sub String

    Hi all,

    I found a function that gave me just what I needed with some tweeking.

    Please see function here:

    http://www.vbaexpress.com/kb/getarticle.php?kb_id=841

    Thanks tigeravatar for your response.


    regards,

    BDB

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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