Hi,
Ended up rewriting code rather than go through what was already there.
Sub FindAndCopyRows()
Dim DataListLastRow As Integer
Dim Number As Integer
Dim DataList As Worksheet
Dim i As Integer
Dim j As Integer
Set DataList = Worksheets("Data List")
DataListLastRow = DataList.Cells(65536, 2).End(xlUp).Row
For i = 1 To DataListLastRow
Number = DataList.Cells(i, 2)
For j = 2 To Worksheets.Count
If Worksheets(j).Name = "Heat_" & Number Then GoTo InsertHeat
Next j
Worksheets.Add After:=Worksheets(Worksheets.Count)
Worksheets(Worksheets.Count).Name = "Heat_" & Number
InsertHeat:
DataList.Select
With Worksheets("Heat_" & Number)
DataList.Rows(i).Copy
Paste (.Cells(65536, 1).End(xlUp).Offset(1, 0))
End With
Next i
End Sub
This will work it's way down column B and copy the contents of the entire row to a new sheet called "Heat_x" depending on the value in column B.
I advise you make sure only the Worksheet "Data List" is present befroe running it (i.e. delete Sheets 2 and 3 if present).
Is this doing pretty much what you require? If you need anything more post back.
Note - This could also be handy whilst you're testing this----
If you want to get back to just having your data list sheet after having generated 100+ sheets that you don't want (happened to my whilst developing this
) then use the following code to do it quickly (though ensure Data List is worksheet 1!!)
Sub ClearWorksheets()
Dim i As Integer
Do While Worksheets.Count > 1
Worksheets(Worksheets.Count).Delete
Loop
End Sub
Tris
Bookmarks