+ Reply to Thread
Results 1 to 7 of 7

Search For string in TextBoxes

  1. #1
    Registered User
    Join Date
    08-12-2013
    Location
    Denton, Texas
    MS-Off Ver
    Excel 2010
    Posts
    89

    Search For string in TextBoxes

    Hello,

    I am trying to loop through a group of TextBoxes. If the TextBox contains the string "FAIL" in it then the next line of code should execute. But I seem to be doing something wrong . I figured that I could use an array to accomplish this. Below is what I have so far...

    Thank you!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Search For string in TextBoxes

    Why not read the values directly into the strTxtArray

    Please Login or Register  to view this content.
    The arguments in InStr are in the wrong order. Also, InStr is case sensitive, that might also throw some things off

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    08-12-2013
    Location
    Denton, Texas
    MS-Off Ver
    Excel 2010
    Posts
    89

    Re: Search For string in TextBoxes

    Hey Mikerickson,

    The only problem I worry about is I have about 50 more other Textboxes that I don't want to loop thru'. By using the generic "TextBox" in the code wont it loop thru' everything when using the below?

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-12-2013
    Location
    Denton, Texas
    MS-Off Ver
    Excel 2010
    Posts
    89

    Re: Search For string in TextBoxes

    I am doing something wrong because I'm getting a subscript out of range error.

    Please Login or Register  to view this content.

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Search For string in TextBoxes

    Notice that the line: If InStr(1, strTextArray(i), "FAIL") <> 0 Then
    is outside of the For..Next loop, so the the value of i is 22 and the array has no element 22. The Next i should be after the line Msgbox...
    Ben Van Johnson

  6. #6
    Registered User
    Join Date
    08-12-2013
    Location
    Denton, Texas
    MS-Off Ver
    Excel 2010
    Posts
    89

    Re: Search For string in TextBoxes

    <---shaking my head in embarrassment...

    Sorry, really long night while I juggle one project from another.

    Thank you!

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Search For string in TextBoxes

    You can do this with a single loop. Eve

    Please Login or Register  to view this content.

+ 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. [SOLVED] can not search textboxes
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-26-2013, 03:24 PM
  2. [SOLVED] textboxes change value on search
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-05-2013, 05:55 PM
  3. [SOLVED] Search for string across header row, then search for another string down found column
    By TucsonJack in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2012, 02:09 PM
  4. Using a string to reverse fill Textboxes on a userform
    By VBA Noob in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-27-2009, 03:27 PM
  5. search a string withing a string : find / search hangs
    By itarnak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-24-2005, 11:05 AM

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