+ Reply to Thread
Results 1 to 4 of 4

Looping through all sheets not working

  1. #1
    Registered User
    Join Date
    06-10-2013
    Location
    boston
    MS-Off Ver
    Excel 2010
    Posts
    79

    Looping through all sheets not working

    I havea macro to loop through all the sheets in a workbook and apply a fliter in column C. the filter is by Date and all sheets have the exact same format. For some reason the macro will go through the loop but not change to the next sheet. The message box line however does go from sheet to sheet.

    Please Login or Register  to view this content.
    I attached a 2 tab work book example. When i run the program, it only applies it to Sheet 1.

    Any help would be great.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Looping through all sheets not working

    Hi, try adding Sheets(I).select as the first line of your for loop.

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

    Re: Looping through all sheets not working

    You aren't referencing the worksheets in the loop.

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    06-10-2013
    Location
    boston
    MS-Off Ver
    Excel 2010
    Posts
    79

    Re: Looping through all sheets not working

    Worked Like a charm, thank you. One question, what can i add to the end of the loop so it will not get an error after the last sheet?

+ 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: 1
    Last Post: 10-04-2013, 04:21 AM
  2. [SOLVED] On Error Goto statement not working when looping
    By som3on3_10 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-21-2013, 12:58 PM
  3. [SOLVED] Looping through sheets to clear a specified range, but excluding some sheets
    By d.sanchez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-03-2013, 02:39 PM
  4. [SOLVED] Multiple Sheets be reflected in 1 sheets as a summary (looping)
    By Kooper in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2012, 03:21 AM
  5. Worksheet Looping not working for all the sheets
    By Blue_kul in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 01-02-2012, 11:09 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