View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default copy sheets selected on user form

Dim bFirst as Boolean
Dim i as long, wkbk as workbook
bFirst = True
for i = 0 to me.lstWorksheets.ListCount - 1
if me.lstworksheets.Selected(i) then
if bFirst then
worksheets(me.lstWorksheets.List(i)).copy
set wkbk = Activeworkbook
bFirst = False
else
worksheets(me.lstWorksheets.List(i)).copy _
After:=wkbk.Worksheets(wkbk.Worksheets.count)
end if
Next

--
Regards,
Tom Ogilvy

"Eileen" wrote in message
...
I have a workbook with several sheets. A user form lists the sheet names

in a
multi select list, lstWorksheets. When the user clicks OK, I want to copy

all
selected sheets to one new workbook. Can someone please help me with the

code
to accomplish this? Thanks.