Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sheets.Add(Before:=Sheets(1)).Name = "Below 70"
  2. Worksheets("Below 70").Range("A1:D1").Value = Array("StudentID", "Last Name", "First Name", "Email")
  3.  
  4. Dim i As Integer, j As Integer
  5. i = 2
  6. j = 5
  7.  
  8. Dim currentStudent() As Variant
  9. Dim newStudent as Integer, newScore as Integer
  10. newStudent = 2
  11.  
  12. Do While Cells(i, 1).Value <> ""
  13.   currentStudent = Range(Cells(i,1), Cells(i,4))
  14.   newScore = 5
  15.   Do While Cells(i, j).Value <> ""
  16.     If Cells(i, j).Value < 70 And newScore = 5 Then
  17.       Worksheets("Below 70").Range(Cells(newStudent,1), Cells(newStudent,4)).Value = currentStudent
  18.       Worksheets("Below 70").Range(Cells(newStudent,newScore)).Value = Range(Cells(1,j)).Text & ":" & Chr(10) & Range(Cells(i,j)).Text
  19.       newScore = newScore + 1
  20.     ElseIf Cells(i, j).Value < 70 And newScore > 5 Then
  21.       Worksheets("Below 70").Range(Cells(newStudent,newScore)).Value = Range(Cells(1,j)).Text & ":" & Chr(10) & Range(Cells(i,j)).Text
  22.       newScore = newScore + 1  
  23.     End If
  24.  
  25.     If newScore > 5
  26.       newStudent = newStudent + 1
  27.     j = j + 1
  28.   Loop
  29.   i = i + 1
  30. Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement