+ Reply to Thread
Results 1 to 5 of 5

substring matching functions (need a hand please)

  1. #1
    Registered User
    Join Date
    01-31-2006
    Posts
    6

    substring matching functions (need a hand please)

    Hi all, I am a very new Excel macro functions user.

    I was looking for a function able to check if a substring is or not present in another string.

    i.e. if the string "--------AB-------" contains the string "AB"

    sorry for the newbie question and thx all

  2. #2
    Registered User
    Join Date
    01-31-2006
    Posts
    6
    I just found the answer

    function InStr ( "String1", "String2" )

  3. #3
    Norman Jones
    Guest

    Re: substring matching functions (need a hand please)

    Hi Ciccio_Drink,

    Look at the InStr function in VBA help:

    '=============>>
    Public Sub Tester001()
    Dim sStr As String

    sStr = " A horse, my Kingdom for a horse"

    If InStr(1, sStr, "xhorse", vbTextCompare) > 0 Then _
    MsgBox "substring found!"

    End Sub
    '<<=============


    ---
    Regards,
    Norman



    "Ciccio_Drink" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Hi all, I am a very new Excel macro functions user.
    >
    > I was looking for a function able to check if a substring is or not
    > present in another string.
    >
    > i.e. if the string "--------AB-------" contains the string "AB"
    >
    > sorry for the newbie question and thx all
    >
    >
    > --
    > Ciccio_Drink
    > ------------------------------------------------------------------------
    > Ciccio_Drink's Profile:
    > http://www.excelforum.com/member.php...o&userid=31003
    > View this thread: http://www.excelforum.com/showthread...hreadid=506710
    >




  4. #4
    Norman Jones
    Guest

    Re: substring matching functions (need a hand please)

    Hi Ciccio_Drink,

    To see the message, replace "xhorse" with "horse"

    ---
    Regards,
    Norman



    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Ciccio_Drink,
    >
    > Look at the InStr function in VBA help:
    >
    > '=============>>
    > Public Sub Tester001()
    > Dim sStr As String
    >
    > sStr = " A horse, my Kingdom for a horse"
    >
    > If InStr(1, sStr, "xhorse", vbTextCompare) > 0 Then _
    > MsgBox "substring found!"
    >
    > End Sub
    > '<<=============
    >
    >
    > ---
    > Regards,
    > Norman




  5. #5
    Registered User
    Join Date
    01-31-2006
    Posts
    6

    Smile

    thank you very much Norman,

    Ciccio

+ 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