+ Reply to Thread
Results 1 to 6 of 6

Anyone know a loop for this?

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Anyone know a loop for this?

    Hi I want to know which will be the best way to loop this:

    Step1:
    For x to y
    IF FOUND
    GoTo Step2
    If NOT FOUND
    GoTo Step1 'redo for the next loop
    If THIS
    Goto EXIT

    Step2:
    For x to y
    IF FOUND
    GoTo Step3
    If NOT FOUND
    GoTo Step2 'redo for the next loop
    If THIS
    Goto EXIT

    Step3:
    For x to y
    IF FOUND
    GoTo Step4
    If NOT FOUND
    GoTo Step3 'redo for the next loop
    If THIS
    Goto EXIT

    Step4: 'final step so go EXIT.
    For x to y
    IF FOUND
    GoTo EXIT
    If NOT FOUND
    GoTo Step4 'redo for the next loop
    If THIS
    Goto EXIT

    EXIT:
    Redim...(blabla)
    Exit Sub
    Thanks.

  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: Anyone know a loop for this?

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Anyone know a loop for this?

    Plese use code tags with your code.
    IMO, None of them!
    If you have read Dummies book for programming by John, it is a terrible coding to use goto.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Anyone know a loop for this?

    What are you actually looping through and what are you trying to find?
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Anyone know a loop for this?

    I have 5 textbox on my userform. I need to validate if each box can be found on my external application.
    The code between the IF is used by my application. It's a function.
    The application will read the row 1 on the application, if it cant find, it will go to next row until row 9 (last row) of the screen. (Thats why the for x to y is used for)
    If it can find, then step2 is the next inputbox to scan between those rows.
    The exit door is in case it cannot find at all, it will stop the scan.

    I dont know about ubound :/

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Anyone know a loop for this?

    You don't really need a loop for that.

    Functions/code can be used to search for the values in the textboxes in the range, and if not found the sub can be exited.

+ 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. HOW TO: Pause loop, fix error on a popup UserForm, continue loop
    By AndyMachin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-19-2014, 04:37 PM
  2. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  3. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  4. Replies: 0
    Last Post: 07-20-2010, 11:42 AM
  5. Loop a column on Sheet1 and loop a row on Sheet2 to find a match
    By johnnywinter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-13-2009, 02:09 PM

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