View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default selecting sheets and copy them to a workbook

As long as there will be at least two adjacent cells with sheet names:

Sub Copysheets1()
Dim varr As Variant
Dim rng As Range
Set rng = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
varr = Application.Transpose(rng)
Debug.Print LBound(varr, 1), UBound(varr, 1)
Sheets(varr).Copy
End Sub

--
Regards,
Tom Ogilvy

"Stephan Otto" wrote in message
...
Tom Ogilvy schrieb:

How do you decide which sheets


By reading a specific column. All sheets, that are mentioned in that

column,
should be copied...

Variant does work

Sub copysheets()
Dim list As Variant
ReDim list(0 To 2)
list(0) = "Sheet1"
list(1) = "Sheet2"
list(2) = "Sheet3"
Sheets(list).Copy

End Sub

worked fine for me. (also, no need to select them first).


Thanks, I will try it this evening. This computer runs Linux...

--
--
http://www.reparco.com - Die kostenlose, persönliche Startseite