+ Reply to Thread
Results 1 to 7 of 7

Instr Function

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

    Instr Function

    Hi,
    This is a portion of a larger Save event for a userform:

    On the userform the user chooses a combobox value.
    If the user chooses, in this case, Sundried Tomatoes,
    I would like to
    1. determine if Textbox12 contains text
    2. compare that text to a number of terms (jar, jarred, packed in oil)

    If any of theses terms are present, to raise a MsgBox event informing the user what to do.
    Then, once the OK button is clicked, run a Clear_MultiPageControls sub.

    If the condition is false just move along with the rest of the code.

    My code does not seem to either check for the terms or raise the MsgBox event.

    How do I fix this?

    Please Login or Register  to view this content.

    Thanks
    Mark
    Last edited by max57; 05-01-2010 at 03:48 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Instr Function

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    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

    Please Login or Register  to view this content.
    That expression will only return True if the entire phrase "jar jarred packed in oil" appears in the textbox.

    This line will never be executed with the Exit Sub appearing immediately above it:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

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

    Re: Instr Function

    Shg,


    RE: Textbox -- In this instance, is there a method by which I could enter multiple terms to be checked against?

    RE: Clear_MultipageControls: I will change that

  5. #5
    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

    Please Login or Register  to view this content.

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

    Re: Instr Function

    Thanks Shg,

    That did the trick!

    Here's the finished code:
    Please Login or Register  to view this content.
    Last edited by max57; 05-01-2010 at 03:53 PM.

  7. #7
    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

    Good job.

    Testing for jarred is redundant if you've tested for jar.

+ 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