Copy Selected sheets to a new workbook and save

iamdeeflow

New Member
Joined
May 10, 2018
Messages
3
Hi everyone,

I've been trying to work on this project but it seems I'm going nowhere.
What I'm trying to do is to copy all sheets that has the same month. The sheets are named as "MAY 01", "MAY 02", "MAY 03" and so on. I have an InputBox to enter the month.

Here's my code. Appreciate who can help me on this.

Code:
Sub MONTHLYFILE()
    Dim mSheets As String
    Dim ws As Worksheet
    mSheets = InputBox( _
        PROMpT:="Enter date in 'MMM' format", _
        Title:="Create Monthly File", _
        Default:="MMM")
        Select Case StrPtr(mSheets)
        Case 0
            Exit Sub
        Case Else
    For Each ws In ActiveWorkbook.Sheets
        If InStr(1, ws.Name, mSheets) <> 0 Then
            ws.Select False
        End If
    Next ws
    End Select
        'dont know what code to copy the selected sheets
        Set WB = ActiveWorkbook
        WB.SaveAs "REV " & mSheets & " 2018.xlsx"
        WB.Close
End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You said:
What I'm trying to do is to
copy all sheets
that has the same month.
Copy the sheet and do what with it?
 
Upvote 0
Thanks for the reply. I wanted to copy the sheets that has the same month to a new workbook and save it. I hope answered your question.
 
Upvote 0
How about add this line to your code
Code:
End Select
[COLOR=#ff0000]ActiveWindow.SelectedSheets.Copy[/COLOR]
Set wb = ActiveWorkbook
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,731
Messages
6,126,537
Members
449,316
Latest member
sravya

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top