My macro accurately creates 2 lists of numerical data based on which group (control or exposed) a subject is in.
Dim Subjects As Integer
Subjects = Sheets("Participant Info").Range("C4:C39").Count
Dim group As String, Rspns As Long
Dim r As Long, i As Long, j As Long
Dim arC, arE
ReDim arC(1 To Subjects)
ReDim arE(1 To Subjects)
With Sheets("Participant Info")
For r = 4 To Subjects + 3
group = .Cells(r, "E").Value
Rspns = .Cells(r, "C").Value
If group = "Control" Then
i = i + 1
arC(i) = Rspns
End If
If group = "Exposed" Then
j = j + 1
arE(j) = Rspns
End If
Next
End With
Sheets("PRISM-Ready").Activate
For i = 1 To i
Sheets("PRISM-Ready").Cells(i + 2, 1).Value = arC(i)
Next
For j = 1 To j
Sheets("PRISM-Ready").Cells(j + 2, 2).Value = arE(j)
Next
Now I am trying to create 2 lists of subject responses (control vs exposed) but this time with TEXT data (responses are either "NA", "Never", "Rarely", "Sometimes" and "Frequently"). Then I want to further break down this down with the total number of each response from each group. Below should give me the number "7" in cell "F163" on Sheets "PRISM-Ready" meaning in the control group, the answer "NA" was given 7 times in a survey.
Dim NAcount As String, Ncount As String, Rcount As String, Scount As String, Fcount As String
Dim arNA, arN, arR, arS, arF
Dim CHCars As String, Cars As String, Cars1 As String
With Sheets("Participant Info")
For r = 4 To Subjects + 3
group = .Cells(r, "E").Value
CHCars = .Cells(r, "F").Value
If group = "Control" Then
Cars = Cars + 1
arC(Cars) = CHCars
End If
If group = "Exposed" Then
Cars1 = Cars1 + 1
arE(Cars1) = CHCars
End If
Next
End With
For **Cars** = 1 To UBound(arC)
If arC(Cars) = "NA" Then
NAcount = NAcount + 1
arNA(NAcount) = CHCars
End If
Next
Sheets("PRISM-Ready").Activate
Sheets("PRISM-Ready").Cells("F163").Value = arNA(NAcount).Count
When I run this code I get "Compile error: Type mismatch", and it highlights Cars in the code (I only added the "**" to show where the error is occuring). I'm pretty sure it has something to do with my use of Strings, or Variants, Long, etc. Any help will be appreciated.
So far I have tried changing Long to String or variant. Both give me Error 13: Type mismatch.

Dim CHCars As Long, Cars As Long, Cars1 As LongarNA(NAcount) = CHCarssinceCHCarsis the last value assigned in theFor r = 4 To Subjects + 3loop. Also whyarNA(NAcount).Countrather than justNAcount? . AlsoRspns = .Cells(r, "C").Valuebut thenarC(i) = age?. I recommend you addOption Explicitas first code line.