Este es el código por facultad adscrita
Private Sub ComboBox2_Change()
'Por.Dante Amor
'Reporte x facultad Adscrita
Application.ScreenUpdating = False
Set h1 = Sheets("formato")
Set h2 = Sheets("Rep x Facultad")
Set h3 = Sheets("asignaciones")
Set h4 = Sheets("DOCENTE")
h2.Cells.Clear
'
u = h3.Range("A" & Rows.Count).End(xlUp).Row
With h3.Sort
.SortFields.Clear: .SortFields.Add Key:=h3.Range("A2:A" & u)
.SetRange h3.Range("A1:F" & u): .Header = xlYes: .Apply
End With
'
n = 1
For i = 2 To h3.Range("A" & Rows.Count).End(xlUp).Row
Set b = h4.Columns("A").Find(h3.Cells(i, "A"), LookAt:=xlWhole)
If Not b Is Nothing Then
If h4.Cells(b.Row, "B") = ComboBox2 Then
ant = h3.Cells(i, "A")
h1.Rows(1).Copy h2.Range("A" & n)
n = n + 1
col = "A"
'
For j = i To h3.Range("A" & Rows.Count).End(xlUp).Row + 1
If ant <> h3.Cells(j, "A") Then
h1.Rows(3).Copy h2.Range("A" & n)
h2.Cells(n, "F") = Totalhoras
'If i > fin Then Exit For
col = "A"
n = n + 4
'h1.Rows(1).Copy h2.Range("A" & j)
'j = j + 1
Totalhoras = 0
i = j - 1
Exit For
End If
h1.Rows(2).Copy h2.Range("A" & n)
h3.Range(h3.Cells(j, col), h3.Cells(j, "F")).Copy
h2.Cells(n, col).PasteSpecial xlValues
col = "B"
n = n + 1
Totalhoras = Totalhoras + h3.Cells(j, "F")
ant = h3.Cells(j, "A")
Next
End If
End If
Next
Application.ScreenUpdating = True
h2.Select
End
End Sub