Try this code -
Option Explicit
Sub scoring()
Dim i As Long, j As Long, lcol As Long, lrow As Long
Application.ScreenUpdating = False
Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = "Summary"
Worksheets("Summary").Range("A1:D1").Value = Split("Respondent name, Question, Correct Answer,Answered Incorrectly", ",")
Worksheets("Summary").Rows(1).Font.Bold = True
With Worksheets("Questions and Answers")
lcol = .Range("IV1").End(xlToLeft).Column
For j = 3 To lcol
For i = 2 To 26
If .Cells(i, j).Value = Worksheets("Correct Answer").Range("C" & i).Value Then
.Cells(27, j).Value = .Cells(27, j).Value + 1
Else
.Cells(28, j).Value = .Cells(28, j).Value + 1
.Cells(i, j).Interior.Color = 255
Worksheets("Correct Answer").Range("D" & i).Value = Worksheets("Correct Answer").Range("D" & i).Value + 1
lrow = Worksheets("Summary").Range("A" & Rows.Count).End(xlUp).Row
Worksheets("Summary").Range("A" & lrow + 1).Value = .Cells(1, j).Value
Worksheets("Summary").Range("B" & lrow + 1).Value = .Cells(i, 2).Value
Worksheets("Summary").Range("C" & lrow + 1).Value = Worksheets("Correct Answer").Cells(i, 3).Value
Worksheets("Summary").Range("D" & lrow + 1).Value = .Cells(i, j).Value
End If
Next i
.Cells(29, j).FormulaR1C1 = "=COUNTA(R[-26]C:R[-2]C)"
.Cells(30, j).Value = .Cells(27, j) / .Cells(29, j)
If .Cells(28, j).Value = "" Then .Cells(28, j).Value = "0"
.Cells(30, j).NumberFormat = "0%"
Next j
End With
Worksheets("Summary").Cells.EntireColumn.AutoFit
MsgBox "Done"
Application.ScreenUpdating = True
End Sub
Bookmarks