+ Reply to Thread
Results 1 to 18 of 18

writing a loop to parse multiple sheets.

  1. #1
    Registered User
    Join Date
    11-01-2006
    Posts
    24

    writing a loop to parse multiple sheets.

    Hello,

    i'm looking for help writing a loop that will perform the same action on 11 worksheets but stop if it gets to a sheet with no data in cell A1. The data in A1 will be text. The code I wrote below below does what I want it to, but I have to run it on each individual sheet. Any help would be greatly appreciated.

    ~Donny

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Does this help

    Please Login or Register  to view this content.

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    11-01-2006
    Posts
    24
    Thanks for the help, but this doesn't work.

    Any other ideas?

    ~Donny

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

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

  5. #5
    Registered User
    Join Date
    11-01-2006
    Posts
    24
    I think this will work, but I think I need to tell it what range of worksheets to parse as I don't want it to parse every worksheet in the workbook. Sorry, I should have been more clear in my description.


    ~Donny

  6. #6
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Hi, Donny. Will you need to list each worksheet? Or how exactly do you determine on which sheets this procedure will run?

    Jason

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    This routine will loop through the sheets of a workbook and, depending on the contents of A1 of that sheet, either:
    Parse the sheet,
    Skip that sheet and go to the next, or
    Stop parsing and exit the routine.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-01-2006
    Posts
    24
    Jason,

    I suppose I would need to list each worksheet by name so that only specific sheets were processed.

    Mike,

    Thanks, i will try this out as well.

    ~Donny

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

    It should be easy to adapt the code I posted.

    Can you give more details on which sheets you do want to parse and which you don't?

  10. #10
    Registered User
    Join Date
    11-01-2006
    Posts
    24
    For instance if I had 15 sheets in the workbook but only wanted to parse sheet 3 though sheet 14.

    ~Donny

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

    But how exactly would you determine that?

    Would it be based on sheet name?

    Sheet position?

  12. #12
    Registered User
    Join Date
    11-01-2006
    Posts
    24
    Sheet name

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    And those sheet names would be?

  14. #14
    Registered User
    Join Date
    11-01-2006
    Posts
    24
    The names of the sheets can change and sheetes can be added/removed over time, so I think I need something where I could modify the names of the sheets as needed, I 'm just not sure how to do this.

    Possibly if you could give me an example using sheet2, sheet 3, sheet 4, to sheet 12. The sheets would always be consecutive but not always starting with sheet 1 or ending with the last sheet.

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    Something like this perhaps.
    Please Login or Register  to view this content.

  16. #16
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Another option would be to create a userform with a listbox and command button. The listbox could be populated with all sheet names, and you could select the sheets to which you would like to apply the procedure.

    You could use code similar to this for the userform:
    Please Login or Register  to view this content.
    HTH

    Jason

  17. #17
    Registered User
    Join Date
    11-01-2006
    Posts
    24
    I'll try this as soon as I get chance and let you know.

    Thanks so much,

    ~Donny

  18. #18
    Registered User
    Join Date
    11-01-2006
    Posts
    24
    Norie,

    Thanks so much for your help, this works perfectly. Thanks to everyone else as well, this is a really great forum.

    ~Donny

    (I'm learning.....slowly)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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