Uploaded by Mathhero M

Option Explicit

advertisement
Option Explicit
Sub MyStuNames()
Dim Rng1 As Worksheet, Rng2 As Worksheet, T As String, Y As Integer, X As Double, Cel As Range, i As Integer
Application.ScreenUpdating = False
Set Rng1 = Worksheets("StudNames"): Set Rng2 = Worksheets("Analysis")
T = Rng2.[AB1]
X = Application.CountIf(Rng1.Range("B:B"), T)
Y = IIf(Range("LangCod") = 2, 5, 4)
Rng2.Range("B8:C42") = Empty
i = 1
For Each Cel In Rng1.Range("B2:B" & Rng1.Cells(Rows.Count, 2).End(xlUp).Row)
If Cel = T Then
Rng2.Cells(7 + i, "B").Value = i
Rng2.Cells(7 + i, "C").Value = Rng1.Cells(Cel.Row, Y).Value
i = i + 1
End If
Next
Application.ScreenUpdating = True
End Sub
Set rng1 = Worksheets("StudNames"): Set rng2 = Worksheets("Analysis")
S = Mid(rng2.[AB1], 1, Len(rng2.[AB1]) - 1) & "-" & Right(rng2.[AB1], 1): t = rng2.[AB1]
X = Application.CountIf(rng1.Range("B:B"), S) + Application.CountIf(rng1.Range("B:B"), t)
Y = IIf(Range("LangCod") = 2, 5, 4)
rng2.Range("B8:C42") = Empty
For i = 1 To X
rng2.Cells(7 + i, "B").Value = i
For Each cel In rng1.Range("B2:B5000")
If (cel = S Or cel = t) And cel.Offset(0, -1) = i Then _
rng2.Cells(7 + i, "C").Value = rng1.Cells(cel.Row, Y).Value
Next
Next
Download