Here you go. I made two versions. 1 adds all the data to the same sheet, with the headers still there so you can tell where the break is. The other adds the data to separate sheets. Note that if possible, you should change your naming convention to either always abbreviate or always use the full month name. It will make everything easier in the future if you need to change this code. For the time being, I had to make the code check for both cases.
Sub gatherInfoNewSheets()
Dim mo&, yr As Long
Dim wb As Workbook
Dim path As String
Set wb = ThisWorkbook
path = "C:\Users\k64\Downloads\"
For yr = 2014 To 2014
For mo = 1 To 4
If Len(Dir(path & "COMMISSION " & MonthName(mo, True) & " " & yr & ".xlsx")) > 0 Then
With Workbooks.Open(path & "COMMISSION " & MonthName(mo, True) & " " & yr & ".xlsx")
.Sheets(1).UsedRange.Copy wb.Sheets.Add.Range("a1")
.Close False
End With
Else
With Workbooks.Open(path & "COMMISSION " & MonthName(mo) & " " & yr & ".xlsx")
.Sheets(1).UsedRange.Copy wb.Sheets.Add.Range("a1")
.Close False
End With
End If
Sheets(Sheets.Count - mo).Name = MonthName(mo)
Next mo
Next yr
End Sub
Sub gatherInfo()
Dim mo&, yr As Long
Dim wb As Workbook
Dim path As String
Set wb = ThisWorkbook
path = "C:\Users\k64\Downloads\"
For yr = 2014 To 2014
For mo = 1 To 4
On Error Resume Next
With Workbooks.Open(path & "COMMISSION " & MonthName(mo, True) & " " & yr & ".xlsx")
.Sheets(1).UsedRange.Copy wb.Sheets(1).Range("a50000").End(xlUp).Offset(1)
.Close False
End With
With Workbooks.Open(path & "COMMISSION " & MonthName(mo) & " " & yr & ".xlsx")
.Sheets(1).UsedRange.Copy wb.Sheets(1).Range("a50000").End(xlUp).Offset(1)
.Close False
End With
On Error GoTo 0
Next mo
Next yr
End Sub
Bookmarks