ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Array Sheets Copy to new Workbooks (https://www.excelbanter.com/excel-programming/313816-array-sheets-copy-new-workbooks.html)

Witek Kruk

Array Sheets Copy to new Workbooks
 
I would like to copy diffrent sheets to new workbook, but I have in many
ways error massage.

I tried take worksheets name to array with FOR .. NEXT,
I try copied multiselected sheets, with number index with the same
results - error massage (range error).

I selected diffrent sheets, that I'm doing well, but I have no idea how
to copy that union (more then 2 sheets).
tx and lol for all sugestion:)
Witek

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom Ogilvy

Array Sheets Copy to new Workbooks
 
worksheets(Array(1,5,7)).Copy

or
Worksheets(Array("sheet1","Sheet5","Sheet7")).Copy

or
Dim varr as Variant
varr = Array(1,5,7)
worksheets(varr).Copy


--
Regards,
Tom Ogilvy


"Witek Kruk" wrote in message
...
I would like to copy diffrent sheets to new workbook, but I have in many
ways error massage.

I tried take worksheets name to array with FOR .. NEXT,
I try copied multiselected sheets, with number index with the same
results - error massage (range error).

I selected diffrent sheets, that I'm doing well, but I have no idea how
to copy that union (more then 2 sheets).
tx and lol for all sugestion:)
Witek

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Witek Kruk

Array Sheets Copy to new Workbooks
 
:))) I solved this problem, instead of Array and string variable I
declared Long variable and used simply Array() (redim etc) with "Long"
variable.

Dim bCount As Byte, m As Byte, lngArray() As Long

bCount = FrmPanel.lstLista2.ListCount
ReDim lngArray(1 To bCount)
For m = 1 To UBound(lngArray)
lngArray(m) = Worksheets(FrmPanel.lstLista2.List(m - 1)).Index
Next m
Worksheets(lngArray).Copy
End If
this work beautifull:)))
Tx Witek


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 12:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com