+ Reply to Thread
Results 1 to 7 of 7

collection of sheets

  1. #1
    mark
    Guest

    collection of sheets

    Hi.

    I'd like to define a collection of sheets that includes
    every sheet in the workbook except the first sheet.

    I recorded that, and it did it with an Array... Sheets
    (Array("Sheet2", "Sheet3", "Sheet4")).select , for example.

    But, when I wrote the program to determine the array, it
    didn't work... in a couple of ways.

    So, I tried it with a sheets variable defined as an array

    but I'm having trouble with it.

    there are a collection of files, to which I need to make
    some changes to every sheet in the file, other than the
    first sheet.

    I'd like to do some of the changes in group mode, if
    possible.

    Is there a good way to do something like

    Sheets(Sheet1!2:8).select ?


    Thanks.

  2. #2
    mark
    Guest

    collection of sheets

    Hello again.

    If there is a simple way to do that, I'd be interested in
    seeing it.

    However, I did get one of the approaches I was working on,
    to work.... define a string array with the sheet names,
    then tell it to select that...

    like this

    stSheetNames(1) = "Sheet2"
    stSheetNames(2) = "Sheet3"
    stSheetNames(3) = "Sheet4"

    sheets(stSheetNames).select

    I set it to Option Base 1 and the assignment is done in a
    loop with Redim Preserve, to make it automated for files
    with a varying number of sheets... I just wrote it as
    above for simplicity of communication.

    But as I said, if anyone knows a simpler, better way, I'd
    like to know, too.

    Thanks,
    Mark

  3. #3
    Tom Ogilvy
    Guest

    Re: collection of sheets

    That is the simpler better way. What's hard about that?

    Just note that VBA provide very little support for working with grouped
    sheets. If you are making changes manually, then that is another story.

    --
    Regards,
    Tom Ogilvy

    "mark" <[email protected]> wrote in message
    news:[email protected]...
    > Hello again.
    >
    > If there is a simple way to do that, I'd be interested in
    > seeing it.
    >
    > However, I did get one of the approaches I was working on,
    > to work.... define a string array with the sheet names,
    > then tell it to select that...
    >
    > like this
    >
    > stSheetNames(1) = "Sheet2"
    > stSheetNames(2) = "Sheet3"
    > stSheetNames(3) = "Sheet4"
    >
    > sheets(stSheetNames).select
    >
    > I set it to Option Base 1 and the assignment is done in a
    > loop with Redim Preserve, to make it automated for files
    > with a varying number of sheets... I just wrote it as
    > above for simplicity of communication.
    >
    > But as I said, if anyone knows a simpler, better way, I'd
    > like to know, too.
    >
    > Thanks,
    > Mark




  4. #4
    Jim Thomlinson
    Guest

    RE: collection of sheets

    How do you know which is the first sheet? If someone moves it around or
    changes the name then you might be hooped... otherwis you can use something
    like this to loop through all of the sheets...

    dim wks as worksheet

    for each wks in worksheets
    if wks.name <> "Whatever" then
    msgbox wks.name
    endif
    next wks

    HTH
    "mark" wrote:

    > Hello again.
    >
    > If there is a simple way to do that, I'd be interested in
    > seeing it.
    >
    > However, I did get one of the approaches I was working on,
    > to work.... define a string array with the sheet names,
    > then tell it to select that...
    >
    > like this
    >
    > stSheetNames(1) = "Sheet2"
    > stSheetNames(2) = "Sheet3"
    > stSheetNames(3) = "Sheet4"
    >
    > sheets(stSheetNames).select
    >
    > I set it to Option Base 1 and the assignment is done in a
    > loop with Redim Preserve, to make it automated for files
    > with a varying number of sheets... I just wrote it as
    > above for simplicity of communication.
    >
    > But as I said, if anyone knows a simpler, better way, I'd
    > like to know, too.
    >
    > Thanks,
    > Mark
    >


  5. #5
    mark
    Guest

    Re: collection of sheets

    >That is the simpler better way. What's hard about that?

    You're right, Tom. That's not all that hard. I just
    started out in the wrong direction... I have worked with
    the Sheets(i) collection a lot, but not with multiple
    sheets at one time, and was trying to access them in a few
    ways that didn't work.

    At first I was looking for something more like the Range
    object... Range(cell1,cell2)... I was looking for
    something like Sheets(Sheet1,Sheet2) with a
    activeworkbook.sheets.count to determine the ending sheet.

    The array, as described earlier, will work fine.

  6. #6
    mark
    Guest

    RE: collection of sheets

    >How do you know which is the first sheet? If someone
    moves it around or changes the name then you might be
    hooped...



    It's a lot of sheets involved, but only 23 files. The
    first sheet. The first sheet is not to be worked with, in
    each case.

    This isn't a production job, it's a one time edit to all
    of the detail sheets, which I am programming, because we
    all know that 'one time edits' tend to be needed many
    times.

    But it's not scheduled to run more.


  7. #7
    mark
    Guest

    Re: collection of sheets

    >Just note that VBA provide very little support for
    working with grouped sheets.

    Yep, I sure do see what you mean.

    Thanks for the warning.

+ 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