+ Reply to Thread
Results 1 to 4 of 4

Repeat Macro for multiple Sheets - Next without For

  1. #1
    Registered User
    Join Date
    10-10-2013
    Location
    New Plymouth, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    2

    Repeat Macro for multiple Sheets - Next without For

    I have multiple sheets with the same layout some have different data. My code goes to each sheet and filters on criteria then copies to another sheet. However, if there is no data it copy it gets stuck.
    I tried putting in an If IsEmpty line so the loop would move to the next sheet but I keep getting a compile error: Next without For.

    I have been searching for hours but am getting no closer to a fix. Here is my code:

    Please Login or Register  to view this content.
    Last edited by Fotis1991; 10-14-2013 at 04:03 AM. Reason: added code tags in this post too!!

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

    Re: Repeat Macro for multiple Sheets - Next without For

    Please use code tags with your code as per forum's rule.
    Please Login or Register  to view this content.
    Is looping through a range in sheet 3, as sheet_name is a range, not a sheet

    You need
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-10-2013
    Location
    New Plymouth, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Repeat Macro for multiple Sheets - Next without For

    Thank you for your advise and sorry for my error.

    I have changed the code as you suggested but I am still getting the error. I have added a line to my code below to show where the error is triggered. I have tried changing the order but get the same compile error.


    Please Login or Register  to view this content.

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

    Re: Repeat Macro for multiple Sheets - Next without For

    It appears to me there are few errors on the code and still more errors to be found.

    Please Login or Register  to view this content.
    This should give you some idea on how to loop through sheet collection


    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] How to repeat a macro in multiple rows of a sheet?
    By rgoodman in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-01-2013, 09:07 AM
  2. [SOLVED] Copy multiple ranges to different sheets and repeat on button click
    By ooze76 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2012, 05:46 PM
  3. Excel 2007 : Repeat Columns in multiple sheets
    By jbode in forum Excel General
    Replies: 1
    Last Post: 01-04-2011, 04:39 PM
  4. macro to repeat on majority but not all other sheets in workbook
    By raehippychick in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-18-2007, 09:15 AM
  5. [SOLVED] VBA Code To have a macro repeat on all sheets in a workbook
    By carl in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-03-2005, 03:50 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