+ Reply to Thread
Results 1 to 4 of 4

selection of several worksheeets

  1. #1
    Enrico
    Guest

    selection of several worksheeets

    Hi

    I'd like to select several excel worksheets using a VBA macro.
    I know: Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")).Select
    But how can I do it without specifying each sheet name?
    For example using something like ... from sheet 3 to sheet 8 ... .Select?

    If possible, please help me.
    Thank you.
    Entaf


  2. #2
    Registered User
    Join Date
    09-22-2003
    Posts
    9
    Hi,
    not much better, but ...
    Sheets(Array(Sheets(2).Name, Sheets(4).Name)).Select

    Jarek

  3. #3
    Tom Ogilvy
    Guest

    Re: selection of several worksheeets

    Sub AA()
    Dim i as Long
    for i = 3 to 8
    worksheets(i).Select i = 3
    Next
    End sub

    would be one way. Another is to build an array, then use that to select the
    sheets

    Sub AB()
    Dim shlist()
    Dim i As Long, k As Long
    ReDim shlist(0 To 5)
    i = 0
    For k = 3 To 8
    shlist(i) = Worksheets(k).Name
    i = i + 1
    Next
    Worksheets(shlist).Select
    End Sub

    --
    Regards,
    Tom Ogilvy


    "Enrico" <[email protected]> wrote in message
    news:[email protected]...
    > Hi
    >
    > I'd like to select several excel worksheets using a VBA macro.
    > I know: Sheets(Array("Sheet1", "Sheet2", "Sheet3", "Sheet4")).Select
    > But how can I do it without specifying each sheet name?
    > For example using something like ... from sheet 3 to sheet 8 ... .Select?
    >
    > If possible, please help me.
    > Thank you.
    > Entaf
    >




  4. #4
    Enrico
    Guest

    Re: selection of several worksheeets

    Thank you very much.
    I got what I needed.

    Entaf


    Tom Ogilvy wrote:

    > Sub AA()
    > Dim i as Long
    > for i = 3 to 8
    > worksheets(i).Select i = 3
    > Next
    > End sub
    >
    > would be one way. Another is to build an array, then use that to select the
    > sheets
    >
    > Sub AB()
    > Dim shlist()
    > Dim i As Long, k As Long
    > ReDim shlist(0 To 5)
    > i = 0
    > For k = 3 To 8
    > shlist(i) = Worksheets(k).Name
    > i = i + 1
    > Next
    > Worksheets(shlist).Select
    > End Sub
    >



+ 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