Hello Seisbye,
The following macro has been added to the attached workbook. There is button on the "Data" sheet to run the macro. I had to rename the sheets "T 1", "T 2", "T 3" to "T1", "T2", "T3". You entered them on the "Data" sheet as "T1", "T2", and "T3".
' Thread: http://www.excelforum.com/excel-programming/806335-sorting-into-multiple-sheets.html
' Poster: Seisbye
' Written: December 19, 2011
' Author: Leith Ross
Sub SortData()
Dim Cell As Range
Dim Dict As Object
Dim DstWks As Worksheet
Dim Item As Variant
Dim Key As Variant
Dim R As Long
Dim Rng As Range
Dim RngEnd As Range
Dim RowData As String
Dim SrcWks As Worksheet
Set SrcWks = Worksheets("Data")
Set Rng = SrcWks.Range("A4")
Set RngEnd = SrcWks.Cells(Rows.Count, Rng.Column).End(xlUp)
If RngEnd.Row < Rng.Row Then Exit Sub Else Set Rng = SrcWks.Range(Rng, RngEnd)
Set Dict = CreateObject("Scripting.Dictionary")
Dict.CompareMode = vbTextCompare
For Each Cell In Rng
Key = Trim(Cell.Offset(0, 2))
Item = CStr(Cell.Row)
If Key <> "" Then
If Not Dict.Exists(Key) Then
Dict.Add Key, Item
Else
Item = Item & "," & Dict(Key)
Dict(Key) = Item
End If
End If
Next Cell
For Each Key In Dict.Keys
Set DstWks = Worksheets(Key)
Set RngEnd = DstWks.Cells(Rows.Count, "A").End(xlUp)
R = IIf(RngEnd.Row < 4, 4, RngEnd.Row + 1)
DataRows = Split(Dict(Key), ",")
For Each Item In DataRows
SrcWks.Rows(CLng(Item)).EntireRow.Copy DstWks.Rows(R)
R = R + 1
Next Item
R = 0
Next Key
End Sub
Bookmarks