hi guys,
Can someone help me, I am looking for a code which will copy output1 and output2 tab from existing worksheet into new worksheet and save the file as XLS.
it should also give the user option to save the file in user define folder and name as they need.
below is my attempt but its does not work and keeps crashing on "Worksheets(Array("Output 1", "Output 2")).Copy"
Code
Private Sub CommandButton1_Click()
Dim UserDirectory As String
UserDirectory = Get_Folder("Enter directory path where ReadMe is to be placed:")
If UserDirectory = "" Then Exit Sub
UserDirectory = UserDirectory & "/"
Worksheets(Array("Output 1", "Output 2")).Copy
ActiveWorkbook.SaveAs Filename:= _
varResult, FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
Sheets(Array("Output 1", "Output 2")).Select
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
Private Function Get_Folder(Optional HeaderMsg As String) As String
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath
.Title = HeaderMsg
If .Show = -1 Then
Get_Folder = .SelectedItems(1)
Else
Get_Folder = ""
End If
End With
End Function
Display More