Userform with Listbox and 2 commandbuttons
Private Sub CommandButton1_Click()
Dim blnReplace As Boolean
Dim shtActive As Object
Dim lngIndex As Long
Dim wbkNew As Workbook
Set shtActive = ActiveSheet
blnReplace = True
For lngIndex = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(lngIndex) Then
ActiveWorkbook.Worksheets(ListBox1.List(lngIndex)).Select blnReplace
blnReplace = False
End If
Next
Set wbkNew = Workbooks.Add
ActiveWindow.SelectedSheets.Copy Before:=wbkNew.Sheets(1)
shtActive.Parent.Activate
shtActive.Select True
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim shtTemp As Worksheet
For Each shtTemp In ActiveWorkbook.Worksheets
ListBox1.AddItem shtTemp.Name
Next
End Sub
Bookmarks