View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
AL AL is offline
external usenet poster
 
Posts: 37
Default Subscript Out of Range

Many Thanks Tom, your utilization of arrays provides for a
very efficient solution.


-----Original Message-----
Sub Test
dim list(0 to 1)
list(0) = "Tab1"
list(1) = "Tab2"
sheets(list).copy
End Test

--
Regards,
Tom Ogilvy


"Al" wrote in

message
...
I'm trying to copy out worksheets Tab1 and Tab2 but am
receiving a subscript out of range error. The

Worksheets
do exist and the code is attached below.

I've simplified this problem, as I do need a Variable
to denote which worksheets will be copied out.

(Otherwise I could have used
Sheets(Array("Tab1","Tab2")).Copy
which works)


Sub test()
Dim s As String

s = """" & "Tab1" & """" & ", " & """" & "Tab2" & """"
Sheets(Array(s)).Copy
End Sub

Thanks in advance.



.