Results 1 to 4 of 4

Thread: Instr Function

  1. #1
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've written the following code but keeps getting an #name error

    Public Function INSTRING(TextSearch, TextFind)

    Dim LPosition As Integer

    LPosition = InStr(1, TextSearch, TextFind, vbTextCompare)

    End Function

    On the worksheet I'm trying to use =instring(Mario,ri) or =instring("Mario","ri")
    and get the same error.

    Where have I missed the plot. TIA

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post
    Mario, try:

    [codebox]Public Function INSTRING(TextSearch, TextFind)

    Dim LPosition As Integer

    LPosition = InStr(1, TextSearch, TextFind, vbTextCompare)

    INSTRING = LPosition

    End Function
    [/codebox]
    Jerry

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    Would it not be simpler to shorten this to
    [codebox]Public Function INSTRING(TextSearch, TextFind)
    INSTRING = InStr(1, TextSearch, TextFind, vbTextCompare)
    End Function
    [/codebox]

  4. #4
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks it work great

Posting Permissions

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