Array Sheets Copy to new Workbooks

W

Witek Kruk

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!
 
T

Tom Ogilvy

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
 
W

Witek Kruk

:))) 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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top