Code as is stands
Dim spath As String
Dim wb2 As Workbook
Dim ws2 As Worksheet
Dim wsd As Range, rng As Range
Sub Portfolio()
Application.ScreenUpdating = False
Set rng = Sheets("Stats").Range("K2:K3")
Set wsd = Sheets("Data").Range("E:E")
spath = "K:\Project Rainbow 3\08. Design\00. Nov2012 Mobilisation\02. FO & C\02 - Project Documents\2013 Branch & Directs RSK 340\02. PROJECT DOCUMENTS\Bank Manager\Private Banking\PF_Cleanse\"
' Start Loop
For Each row In rng
Set wb2 = Workbooks.Add
For Each row1 In wsd
' Searches for portfolio number in data and copies line if found
If row = row1 Then
Selection.End(xlToLeft).Select
Selection.Copy
End If
' Need to insert if rng value not found in wds then next row else keep running code
' Pastes values in new workbook
With wb2
Sheets(1).Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End With
Next row1
wb2.Close
wb2.SaveAs Filename:=spath & rng & ".xlsx"
Next row
Application.ScreenUpdating = True
End Sub
Bookmarks