Try this...
Code:
Sub Consolidator()
Dim wbk As Workbook
Dim wbkNew As Workbook
Set wbk = ThisWorkbook 'if you are running the code from the source file.
'If not, you can refer it to the workbook directly as Workbooks("Data 2010") and replace the above code with
'Set wbk = Workbooks("Data 2010")
'Note that the Workbooks("Data 2010") should be open when the macro is run
Set wbkNew = Workbooks.Add(xlWorksheet)
Dim strMonthFilter As String
strMonthFilter = "1 " & Format(InputBox("Enter Month With Year. Ex: March 2013, or Mar 2013", "Filter Monthly Data", Format(Date, "mmm yyyy"), Application.Width / 2, Application.Height / 2), "mmm yyyy")
If IsDate(strMonthFilter) Then
With wbk.Sheets(1)
.AutoFilterMode = False
.Range("$A$1:$AH$" & .Cells(.Rows.Count, 1).End(xlUp).Row).AutoFilter Field:=12, Operator:=xlFilterValues, Criteria2:=Array(1, strMonthFilter)
.Range("$A$1:$AH$" & .Cells(.Rows.Count, 1).End(xlUp).Row).Copy wbkNew.Sheets(1).Cells(1)
End With
Else
MsgBox "Please enter a valid date in MMMM YYYY format", vbOKOnly, ""
End If
'If you want to save and close the new file, use
wbkNew.SaveAs wbk.Path & Application.PathSeparator & Mid(strMonthFilter, 3)
wbkNew.Close 0
End Sub
Bookmarks