+ Reply to Thread
Results 1 to 4 of 4

Skip to next record in For...Next Loop if condition not met

  1. #1
    Registered User
    Join Date
    11-15-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    97

    Skip to next record in For...Next Loop if condition not met

    Hi,

    I am writing a code that will go down a column C in worksheet Data containing Customer IDs, starting at row 3 and going down to the last populated row
    If a cell contains an ID, I find the row in the Master (worksheet SUBS) for the customer having that ID
    Column P of worksheet SUBS contains the email address of the customer.
    Using this, an email is generated to the customer.

    After finding the customer, if the email address in column P in worksheet SUBS is blank, I want to skip this customer and go to the next row in Worksheet Data.

    The Code I have written is as follows:

    Please Login or Register  to view this content.
    I tried using Exit For, but this exits the loop. I tried to use Resume Next. This gave me an error "Resume without error"

    How do I get the For...Next Loop to continue ? Any help will be greatly appreciated

    Anand

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Skip to next record in For...Next Loop if condition not met

    You could use a do until loop using a variable as the limit and set the variable using an input box. Your code would then find the nth record each time you run it.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

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

    Re: Skip to next record in For...Next Loop if condition not met

    Post a sample workbook (no pictures!). Use dummy email addresses and personal info.
    To attach a Workbook
    (please do not post pictures of worksheets)
    • Click Advanced (next to quick post),
    • Scroll down until you see "Manage Attachments",
    • Click that then select "add files" (top right corner).
    • Click "Select Files" find your file, click "open" click "upload"
    • Once the upload is completed the file name will appear below the input boxes in this window.
    • Click "Done" at bottom right to close the Attachment Manager.
    • Click "Submit Reply"
    Ben Van Johnson

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

    Re: Skip to next record in For...Next Loop if condition not met

    Anand

    You could try it like this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

+ 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 skip filter action if particular value is not found in record
    By shaikh_javed246 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-31-2012, 02:15 PM
  2. [SOLVED] Skip Condition Formatting If Sum of Column Equals Zero
    By pjnelson692 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-22-2012, 05:14 PM
  3. Excel 2007 : Skip columns on condition
    By nlm in forum Excel General
    Replies: 3
    Last Post: 11-25-2011, 01:44 AM
  4. How to skip special cases in a For Each loop
    By smohyee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-16-2011, 02:20 PM
  5. skip hidden rows in loop
    By secondrate in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2010, 08:41 AM

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