Попробуйте следующий код, пожалуйста:
Sub copyToNewSheets()
Dim ws1 As Worksheet, ws2 As Worksheet, rngC As Range, skey As String
Dim i As Long, j As Long, lastCol As Long, iLastRow, jLastRow As Long
Dim Wb As Workbook, wsNew As Worksheet, k As Long, rngHeader As Range
Set ws1 = ActiveSheet 'use here your sheet
Set ws2 = Worksheets("SecondSheet") 'use here your sheet, too
iLastRow = ws1.cells(Rows.count, 3).End(xlUp).Row
jLastRow = ws2.cells(Rows.count, 3).End(xlUp).Row
Set rngHeader = ws2.Range("A1:E1")
'Create the new workbook
Set Wb = Workbooks.Add
For i = 1 To Wb.Worksheets.count - 1
Application.DisplayAlerts = False
Wb.Sheets(i).Delete
Application.DisplayAlerts = True
Next i
'for making the code faster:_________________
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
'____________________________________________
lastCol = 5: k = 1
For i = 18 To iLastRow
skey = ws1.cells(i, 3).Value
For j = 2 To jLastRow
If skey = ws2.Range("A" & j).Value Then
If rngC Is Nothing Then
Set rngC = ws2.Range(ws2.Range("A" & j), ws2.cells(j, lastCol))
Else
Set rngC = Union(rngC, ws2.Range(ws2.Range("A" & j), ws2.cells(j, lastCol)))
End If
End If
Next j
If Not rngC Is Nothing Then
If k = 1 Then
Set wsNew = Wb.Sheets(k): k = k + 1
Else
Set wsNew = Wb.Sheets.Add(After:=Wb.Sheets(k - 1)): k = k + 1
End If
wsNew.Name = skey
rngHeader.Copy Destination:=wsNew.Range("A1")
rngC.Copy Destination:=wsNew.Range("A2")
Set rngC = Nothing
End If
Next i
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
MsgBox "Ready...", vbInformation
End Sub