+ Reply to Thread
Results 1 to 4 of 4

Problem using For Each and Next

  1. #1
    Registered User
    Join Date
    04-12-2019
    Location
    Dallas
    MS-Off Ver
    2016
    Posts
    64

    Problem using For Each and Next

    I have ran into this problem a few times and still don't understand why it happens. When I use For Each x then later say Next, it comes back with an error saying invalid use of Next. Could someone help me and explain how to use Next so I can stop running into this problem?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,802

    Re: Problem using For Each and Next

    I don't know if other programming languages allow for multiple loops/counter variables in a single Next statement, but I believe that VBA does not allow this. You need a separate Next statement for each loop.
    Please Login or Register  to view this content.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    04-12-2019
    Location
    Dallas
    MS-Off Ver
    2016
    Posts
    64

    Re: Problem using For Each and Next

    I've tried that as well and it still shows the same error, If it's before the End If or after the End If it still has problems

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,802

    Re: Problem using For Each and Next

    The Next statements should be outside of the block If (after the End If). Can you post an example you have tried with the three Next statements outside of the block If? It should work, unless there is something else I am missing.

+ 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. Replies: 6
    Last Post: 07-01-2018, 01:58 PM
  2. [SOLVED] Excel Macro - Copy & Paste (Font) problem & Delete Last Added Rows problem
    By LennartB in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-05-2015, 06:58 AM
  3. Replies: 6
    Last Post: 10-20-2013, 07:16 PM
  4. input box problem, cell filtering problem, result display while locking sheet
    By croozin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-01-2013, 08:52 AM
  5. Replies: 6
    Last Post: 05-28-2013, 05:08 PM
  6. Replies: 2
    Last Post: 01-22-2013, 07:09 AM
  7. Problem using formulas within macro + problem with defined name.
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2011, 04:39 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