Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default copy sheets selected on user form

Try this Eileen

Private Sub CommandButton1_Click()
Dim arr() As String
Dim N As Integer
N = 0
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
N = N + 1
ReDim Preserve arr(1 To N)
arr(N) = ListBox1.List(i)
End If
Next i
If N = 0 Then
MsgBox "You must select at least one Sheet"
Exit Sub
End If
ThisWorkbook.Worksheets(arr).Copy
Unload Me
End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl


"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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vb code to copy and list selected row to diff sheets pvkutty Excel Discussion (Misc queries) 1 February 17th 10 12:05 PM
Copy specific data form sheets into master sheet Eva Excel Worksheet Functions 6 November 20th 09 06:06 PM
Sending user selected daa from cmblistbx to sheets of destination No Name Excel Programming 0 February 18th 04 08:24 PM
Copy from User form to Sheet macro tas5tas Excel Programming 1 January 13th 04 03:54 AM
Copy one spreadsheet into another without activating second spreadsheet's user form P Cheek Excel Programming 3 July 23rd 03 06:26 PM


All times are GMT +1. The time now is 10:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"