Hi,
I've been around this issue for too long and I believe it's a simple thing to do but I'm just not getting it.
I've a userform (UserForm1) where the user selects the worksheets to copy into a new workbook by checking comboboxes.
After selecting the worksheets, the user click ok (CommandButton1) and it should:
I've some example codes for copying without vba codes, command button and deleting hidden rows/columns.
My biggest issue is to select and copy specific worksheets (defined by the user in the moment) to a new workbook.
Should there be any clarification from my side, please don't hesitate to ask me.
Thank you for your support.
I've been around this issue for too long and I believe it's a simple thing to do but I'm just not getting it.
I've a userform (UserForm1) where the user selects the worksheets to copy into a new workbook by checking comboboxes.
After selecting the worksheets, the user click ok (CommandButton1) and it should:
- select the worksheets associated to the comboboxes;
- copy them;
- paste them into a new workbook without vba codes, command buttons and hidden rows and columns.
Code:
Private Sub CommandButton1_Click()
Unload Me
Dim WS As Worksheet
Dim WB As Workbook
If CheckBox1.Value = True And CheckBox2.Value = True And CheckBox3.Value = True Then
Sheets(Array(Sheet1.Name, Sheet2.Name, Sheet3.Name)).Select
ElseIf CheckBox1.Value = True And CheckBox2.Value = True Then
Sheets(Array(Sheet1.Name, Sheet2.Name)).Select
ElseIf CheckBox1.Value = True And CheckBox3.Value = True Then
Sheets(Array(Sheet1.Name, Sheet3.Name)).Select
ElseIf CheckBox2.Value = True And CheckBox3.Value = True Then
Sheets(Array(Sheet2.Name, Sheet3.Name)).Select
ElseIf CheckBox1.Value = True Then
Sheets(Sheet1).Select
ElseIf CheckBox2.Value = True Then
Sheets(Sheet2).Select
ElseIf CheckBox3.Value = True Then
Sheets(Sheet3).Select
ElseIf CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False Then
Unload Me
UserForm2.Show
Exit Sub
End If
Set WB = Workbooks.Add
For Each WS In ActiveWindow.SelectedSheets
WS.Cells.Copy
WS.[A1].PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
WS.Activate
Next WS
WB.Application.Dialogs(xlDialogSaveAs).Show
End Sub
I've some example codes for copying without vba codes, command button and deleting hidden rows/columns.
My biggest issue is to select and copy specific worksheets (defined by the user in the moment) to a new workbook.
Should there be any clarification from my side, please don't hesitate to ask me.
Thank you for your support.