+ Reply to Thread
Results 1 to 4 of 4

For loop to only work once then exit

  1. #1
    Registered User
    Join Date
    02-21-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    8

    For loop to only work once then exit

    I'm trying to make a For.. Next. that will find the relevant cell in a row starting at the bottom, and then once it has found it, grab the row number and then exit the for.

    Would I do it like:
    Please Login or Register  to view this content.
    Or

    Please Login or Register  to view this content.
    Also instead of matchingRow = x, how do I grab the row number?

    Thanks a lot in advance

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

    Re: For loop to only work once then exit

    i will give you the matching row.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    02-21-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    8

    Re: For loop to only work once then exit

    Oh yeah of course... woops :') But which code do I use for the first question?

  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: For loop to only work once then exit

    The second code you posted should do the job.

    The first won't actually compile as Next i/End If is the wrong way round.

+ 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. Exit Loop If Value Not Matched
    By Coeus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-17-2013, 04:49 AM
  2. [SOLVED] Exit for each loop condition[s]
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 34
    Last Post: 07-16-2013, 10:44 AM
  3. Exit loop
    By ashmott in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-19-2011, 05:41 AM
  4. exit loop when find value?
    By sweetboy02125 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2011, 03:42 PM
  5. [SOLVED] exit for next loop
    By David Henderson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2006, 02:45 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