+ Reply to Thread
Results 1 to 7 of 7

Instr Function - Replace String 2 with Variables?

  1. #1
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Instr Function - Replace String 2 with Variables?

    Hi Folks,


    I would like to create a list of string values for an Instr Function, rather than having to write numerous statements covering each of them.
    I'm thinking that its easier and more flexible to add to a list, than to write additional code.

    So, is it possible to replace the Second String arg of the Instr Function with either of these two options?

    InStr([start, ]string1, string2[, compare])
    • an array of values
    • a named range of values on a sheet

    How would these be dimensioned?
    How would the variables be set?

    I've tinkered with a few variations, but I get all sorts of mismatch errors and procedural bugs.



    Thanks,

    Mark

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Instr Function - Replace String 2 with Variables?

    No, it's not possible.

    But you can write a loop, or use Regular Expressions. If you've never used regular expressions, I would recommend the former.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Instr Function - Replace String 2 with Variables?

    Thanks Shg,
    I've seen some posts on this board utilizing Regular Expressions and will delve further into that.

    I've never seen a Loop in this particular instance.
    In pseudo code, how would this be employed?

    Mark

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Instr Function - Replace String 2 with Variables?

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Instr Function - Replace String 2 with Variables?

    Thanks Shg

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Instr Function - Replace String 2 with Variables?

    You're welcome.

    Here's a place to start for RegExp: http://msdn.microsoft.com/en-us/library/ms974570.aspx

  7. #7
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Instr Function - Replace String 2 with Variables?

    Great Link!

    Extremely informative!

    Much obliged!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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