Forum Discussion

DawnT1967's avatar
DawnT1967
Copper Contributor
Aug 22, 2022

Partial list needed

Hello,

 

I have a list with the general work population and their qualifications. I need to filter the data on separate pages according to department. A pivot doesn't meet requirements.

I need something in the lines of : if the department is called "A" the data is copied to the page called Department A. I have seven departments to account for.

The general data is something along "Dep / Name / First name / qualification a / qualification b"

If possible I would prefer an answer in German as my setup is German.

Thx

Dawn

1 Reply

  • DawnT1967 

    Sub department()
    
    Dim i As Long
    Dim k As Long
    Dim l As Long
    
    l = Range("A" & Rows.Count).End(xlUp).Row
    
    For i = 2 To l
    
    k = Worksheets("Department " & Cells(i, 1).Value).Range("A" & Rows.Count).End(xlUp).Row
    Range(Cells(i, 1), Cells(i, 5)).Copy Destination:=Worksheets("Department " & Cells(i, 1).Value).Cells(k + 1, 1)
    
    Next i
    
    End Sub

    Maybe with this code. In the attached file you can click the button in cell H2 to run the macro.

Resources