+ Reply to Thread
Results 1 to 5 of 5

Check if TextBox contains item from Array

  1. #1
    Registered User
    Join Date
    02-26-2020
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    29

    Check if TextBox contains item from Array

    Hi All,

    I'm trying to get a textbox in a VBA userform to throw an alert if it contains anywhere in the whole box, certain words or phrases dictated by an array.

    Currently, if the TextBox contains ONLY the array item, it works and I get my box to go red. But if the TextBox contains other text i.e. "this that and the other, Option 1 is best" then the TextBox is not highlighted red.


    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Just wondering if anyone can help? I've tried using the Instr method to get things done, but I cant seem to wrap my head around the syntax of it all.

    Any help is much appreciated!

    Cheers

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Check if TextBox contains item from Array

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file.

  3. #3
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Check if TextBox contains item from Array

    Using the InStr function...
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-26-2020
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    29

    Re: Check if TextBox contains item from Array

    Apologies for not attaching the file. I often find trying to disassemble this particular workbook and remove sensitive information takes much longer than it would having just provided the snippet of code I did!

    As it happens @dangelor, that amendment in bold did just the trick! Works a charm! Thank you so much for your help! Will mark thread as solved! It always astounds me how quickly members of this forum are able to digest and analyse code and come up with a working solution! Thanks again

  5. #5
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Check if TextBox contains item from Array

    Glad I could help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Check In/Check Out by Item Number
    By singinwes in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-04-2020, 05:29 PM
  2. [SOLVED] Loop is not triggered when using an array if first item in array is not found
    By Ianmacros in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2019, 01:35 PM
  3. [SOLVED] Highlight textbox if date <=60 days referencing an array as textbox numbers
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-23-2017, 11:43 AM
  4. [SOLVED] Check out and return - Check if entered item is already checked out
    By lostdesigns in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-25-2017, 10:05 AM
  5. [SOLVED] If dictionary key exists add new item to existing item array
    By strud in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-25-2014, 01:54 PM
  6. Textbox value to add item in Combobox
    By puuts in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-14-2013, 06:56 PM
  7. item textbox into cell
    By vroemans in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-12-2007, 02:19 PM

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