Results 1 to 13 of 13

Add-in to saving groups of worksheets as a single workbook

Threaded View

  1. #13
    Registered User
    Join Date
    04-30-2007
    Location
    JerseyCI/London
    Posts
    35
    Someone here has changed their mind and would rather work from one source, in that case I don't need to match from other workbooks.

    In that sense its very easy for me to import all the worksheets into one workbook and create an array to select several sheets which I then bolt more code onto.

    I've implemented this so far but the array only works when 4 sheets are present for each person - anything less is 'outside the range'

    I'm a bit confused about the whole redim/preserve/erase thing. How could I rewrite this so excel knows to look to check for multiple arrays. Nesting this would be ok.

    My four arrays would be.. (and I realise you wouldn't define them like this)

    array1 = Sheets(Array(strname)).select
    array2 = Sheets(Array(strname, strname & " (2)")).select
    array3 = Sheets(Array(strname, strname & " (2)", strname & " (3)")).selectarray4 = Sheets(Array(strname, strname & " (2)", strname & " (3)", strname & " (4)")).select

    Cheers


    Danny

    Function SheetExists(SheetName As String) As Boolean
     'returns TRUE if the sheet exists in the active workbook
        SheetExists = False
        On Error GoTo NoSuchSheet
        If Len(Sheets(SheetName).Name) > 0 Then
            SheetExists = True
            Exit Function
       End If
    NoSuchSheet:
    End Function
    Sub SheetSelect()
    Dim strname As String
    Dim ThisBook As Workbook, WkSht As Worksheet
    Set ThisBook = ThisWorkbook
       
    strname = InputBox(Prompt:="Please enter user code.", _
              Title:="User Code Input")
    
    If Not SheetExists(strname) Then
        MsgBox strname & " doesn't exist!"
    Else
        For Each WkSht In ActiveWorkbook.Worksheets
            Select Case WkSht.Name
               
            Case strname, strname & " (2)", strname & " (3)", strname & " (4)"
                Application.DisplayAlerts = False
                Sheets(Array(strname, strname & " (2)", strname & " (3)", strname & " (4)")).Select
            Case Else
               ' Do Nothing
            End Select
    Next WkSht
    End If
    
    End Sub
    Last edited by VBA Noob; 11-11-2008 at 09:33 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Creating a series of workbooks from single workbook
    By AndrewCrisp in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-05-2009, 01:11 PM
  2. Collecting Worksheets into one Workbook
    By RiverSide in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2008, 11:29 AM
  3. Locking single sheet in workbook
    By scottimus in forum Excel General
    Replies: 3
    Last Post: 04-29-2008, 02:31 PM
  4. Macro moves out of Active WorkBook. Why?
    By ulfah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2008, 01:14 PM
  5. Closing the workbook & saving automatically
    By mwc0914 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-25-2008, 06:18 PM

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