I have refactored the part that puts the data on a worksheet. I wrote it as a stand alone sub until we know exactly what you need.
Note that there are no Magic Numbers in the code. This makes it extremely easy to change the layout of the Report Table. For example, right now the columns are labled "high, Broad, low". If you boss decides he wants to see "Broad, Low, High," you only have to change 3 number charcters in the entire code. Likewise, he s/he wants to see "Mean RT" at the top of the table, you will only have to Cut and Paste two sections of the code.
Sub InsertDataTable(WkBk As Workbook, WkSht As Worksheet, StartCell As Range)
'7 Rows x 4 Columns
'Uses Modular level Variables
' DisplayTypeH
' DisplayTypeB
' DisplayTypeL
'Offset Values As Names
Const Label As Long = 0
Const H As Long = 1
Const B As Long = 2
Const L As Long = 3
Dim Rw As Long 'Row Offset Selector
With WkBk.Sheets(WkSht)
With StartCell
.Value = "Result: "
.Font.Bold = True
End With
Rw = Rw + 1
With .Offset(Rw, Label)
.Value = "Display Type"
.Font.Bold = True
End With
With .Offset(Rw, H)
.Value = "High"
.Font.Bold = True
End With
With .Offset(Rw, B)
.Value = "Broad"
.Font.Bold = True
End With
With .Offset(Rw, L)
.Value = "Low"
.Font.Bold = True
End With
Rw = Rw + 1
With .Offset(Rw, -Label)
.Value = "CorrectInput Number"
.Font.Bold = True
End With
.Offset(Rw, H).Value = DisplayTypeH.TotalCorrectInputs
.Offset(Rw, B).Value = DisplayTypeB.TotalCorrectInputs
.Offset(Rw, L).Value = DisplayTypeL.TotalCorrectInputs
Rw = Rw + 1
With .Offset(Rw, -Label)
.Value = "Total Number"
.Font.Bold = True
End With
.Offset(Rw, H).Value = DisplayTypeH.TotalInputs
.Offset(Rw, B).Value = DisplayTypeB.TotalInputs
.Offset(Rw, L).Value = DisplayTypeL.TotalInputs
Rw = Rw + 1
With .Offset(Rw, Label)
.Value = "CorrectInput Ratio"
.Font.Bold = True
End With
.Offset(Rw, H).Value = DisplayTypeH.TotalCorrectInputs / DisplayTypeH.TotalInputs
.Offset(Rw, B).Value = DisplayTypeB.TotalCorrectInputs / DisplayTypeB.TotalInputs
.Offset(Rw, L).Value = DisplayTypeL.TotalCorrectInputs / DisplayTypeL.TotalInputs
Rw = Rw + 1
With .Offset(Rw, Label)
.Value = "Total RT"
.Font.Bold = True
End With
.Offset(Rw, H).Value = DisplayTypeH.TotalReactTime
.Offset(Rw, B).Value = DisplayTypeB.TotalReactTime
.Offset(Rw, L).Value = DisplayTypeL.TotalReactTime
Rw = Rw + 1
With .Offset(Rw, Label)
.Value = "Mean RT"
.Font.Bold = True
End With
.Offset(Rw, H).Value = DisplayTypeH.TotalReactTime / DisplayTypeH(Rw)
.Offset(Rw, B).Value = DisplayTypeB.TotalReactTime / DisplayTypeB(Rw)
.Offset(Rw, L).Value = DisplayTypeL.TotalReactTime / DisplayTypeL(Rw)
End With 'WkBk.WkSht 'Iraos: In case you forgot, you don't have to scroll up and down to see which With is ending.
End Sub
I also changed the part the gets the data off the workshhet to a stand alone sub
Sub GetData(WkBk As Workbook, WkSht As Worksheet, Optional StartRow As Long = 2)
'Uses Modular level Variables
' DisplayTypeH
' DisplayTypeB
' DisplayTypeL
'And CN_ColumnNumbersAsnames Constants
Dim CorrectInput As Long
Dim Rw As Long
Const Col As Long = 1
Rw = StartRow
With WkBk.Sheets(WkSht)
Do While Cells(Rw, Col) <> "" 'Loop Thru every Row until Column A is empty
If (LCase(Cells(Rw, cnInputResponse)) = "male" And LCase(Cells(Rw, cnGender) = "m")) _
Or (LCase(Cells(Rw, cnInputResponse) = "female" And LCase(Cells(Rw, cnGender)) = "f")) _
Then CorrectInput = 1
Select Case UCase(Cells(Rw, cnDisplayType).Value)
Case "H"
With DisplayTypeH 'A UDT Type Variable. Each member is assigned a different value.
.TotalInputs = .TotalInputs + 1
.TotalCorrectInputs = .TotalCorrectInputs + CorrectInput
.TotalReactTime = .TotalReactTime + Cells(Rw, cnReactTime)
End With
Case "B"
With DisplayTypeB
.TotalInputs = .TotalInputs + 1
.TotalCorrectInputs = .TotalCorrectInputs + CorrectInput
.TotalReactTime = .TotalReactTime + Cells(Rw, cnReactTime)
End With
Case "L"
With DisplayTypeL
.TotalInputs = .TotalInputs + 1
.TotalCorrectInputs = .TotalCorrectInputs + CorrectInput
.TotalReactTime = .TotalReactTime + Cells(Rw, cnReactTime)
End With
End Select
Rw = Rw + 1
Loop
'Note that Rw is now equal to the Row just after the data
End With
End Sub
See the Code on Worksheet2 in the Attachment