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
Bookmarks