Basically, what I want i to sort data from a master sheet to multiple sheets depending on values in a given column of the master sheet. This very same issue has been addressed at http://www.excelforum.com/excel-prog...tml?p=3226790;
I have been inspired by the codes in the link above, and have made this code:
Sub yihaa()
Dim OutSH As Worksheet
Dim DataSH As Worksheet
Set DataSH = Sheets("sheet1")
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
lastrow = DataSH.Cells(Rows.Count, "A").End(xlUp).Row
If Sheets.Count > 1 Then
For i = 2 To Sheets.Count
Sheets(i).Cells.Clear
Next i
End If
For Each ce In DataSH.Range("A1:A" & lastrow)
If Not IsEmpty(ce) Then
arr = Split(ce.Value, ",")
For i = LBound(arr) To UBound(arr)
'add a new sheet if it doesn't exist
If Not sheetexists(Trim(arr(i))) Then
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = Trim(arr(i))
ActiveSheet.Range("A1:H1").Value = Array("anlæg", "areal", "etage", "rumtype", "rumnummer", "luftskifte", "højde", "luftmængde")
End If
Set OutSH = Sheets(Trim(arr(i)))
ce.EntireRow.Copy Destination:=OutSH.Cells(Rows.Count, 3).End(xlUp).Offset(1, -2)
Next i
End If
Next ce
End Sub #
how ever, headings (''anlæg'', ''areal'', ...) are not being copied over in all sheets, meaning that the line below is not working correctly:
''ActiveSheet.Range("A1:H1").Value = Array("anlæg", "areal", "etage", "rumtype", "rumnummer", "luftskifte", "højde", "luftmængde")#.
Is there anybody that can help me fixing this issue?? This is my very first VBA task, 
Tanks in advance
Bookmarks