+ Reply to Thread
Results 1 to 12 of 12

how to loop through all sheets in workbook

  1. #1
    Registered User
    Join Date
    01-27-2017
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    90

    how to loop through all sheets in workbook

    Hi
    i am trying to make this code work through all sheets, this code should check all sheets in work book and delete "abcd", "xyz" values in all sheets.


    Please Login or Register  to view this content.

    please help ,if possible i should be able to skip specific sheet.
    Last edited by narsing18; 05-12-2017 at 05:01 AM. Reason: CODE EDITED

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: how to loop through all sheets in workbook

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,477

    Re: how to loop through all sheets in workbook

    Give this a go:

    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: how to loop through all sheets in workbook

    Please Login or Register  to view this content.
    The 'Case Else' and label 'zz' are not needed...

  5. #5
    Registered User
    Join Date
    01-27-2017
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    90

    Re: how to loop through all sheets in workbook

    Hi
    Its throwing compiler error : expected array

    Thanks

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,659

    Re: how to loop through all sheets in workbook

    I just don't agree with
    Please Login or Register  to view this content.
    It might slow the process.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,659

    Re: how to loop through all sheets in workbook

    Try this
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-27-2017
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    90

    Re: how to loop through all sheets in workbook

    @jindon ...thanks its working perfectly ...as i mentioned in my first post can i skip any particular sheet if possible.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,659

    Re: how to loop through all sheets in workbook

    Just add another Select Case statement like
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    01-27-2017
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    90

    Re: how to loop through all sheets in workbook

    Hi Jindon,

    this is working but there is some problem with this code....if i high lite sheet1 and run the code it skips that sheet and delete the specific rows from all the sheets ,

    but if am high lite any other sheet like sheet3 and run the code its skips the sheet1 and skipping the other sheet like sheet4 and its happening randomly.

    can you please check below is the code i applied.

    Please Login or Register  to view this content.

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,659

    Re: how to loop through all sheets in workbook

    Missed....
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-27-2017
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    90

    Re: how to loop through all sheets in workbook

    its did the trick.....working perfectly....:

+ 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. Looper to Loop through sheets in workbook and copy paste to another workbook
    By amartin575 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2017, 12:57 AM
  2. VBA For Each Loop Saving Sheets to New Workbook
    By djm601 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2014, 07:12 AM
  3. [SOLVED] Loop codes through multiple sheets (not all sheets in workbook)
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-18-2014, 02:11 AM
  4. [SOLVED] loop action through all sheets in workbook skipping certain sheets
    By sawa85sa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2013, 06:40 PM
  5. Loop through sheets in a workbook
    By Mumps1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-21-2012, 08:14 AM
  6. Loop sheets in more than one workbook
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-02-2009, 11:14 AM
  7. Loop through all sheets in workbook
    By jennie in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-26-2005, 07:05 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