+ Reply to Thread
Results 1 to 3 of 3

Selecting sheets with an array of names

  1. #1
    Registered User
    Join Date
    02-03-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    2

    Selecting sheets with an array of names

    Hello, my first post so be nice

    I more or less started with VBA and Excel yesterday so this might be obvious to most of you but I have been wrestling with this problem for 2 hours now.

    What i want to do is use the find-operation on a dynamic number of worksheets, here is my code:

    Dim count As Integer
    Dim MySheets() As String
    Dim Max As Integer

    Max = ActiveWorkbook.Worksheets.count
    ReDim MySheets(1 To Max)
    For count = 1 To Max
    MySheets(count) = ActiveWorkbook.Worksheets(count).Name
    Next count

    FindString = sheets("Search").Range("J10").Value
    If Trim(FindString) <> "" Then
    With sheets(MySheets).Range("E7:Q33")

    And then my find-operation is performed on the range, and that operation works when I type in a specified worksheet to perform it on. The problem is this line of code: With sheets(MySheets).Range("E7:Q33")

    It wont allow me to use my array of the names of the worksheets to select those i want to.
    Any ideas why I cant?

    Thanks! Mike

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997

    Re: Selecting sheets with an array of names

    You can't do them all at once - you will have to loop through your array of sheet names and do each sheet in turn.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    02-03-2010
    Location
    Sweden
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Selecting sheets with an array of names

    Okay, IŽll just have to loop through them then I guess, thank you for your help!

+ 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