Hello everyone,
I have the following problem:
I have multiple answers test and I have answers for two questions for some number of people. This produce two tables (two ranges). I would like to count all people that have the same answers for both questions. I tried function CountIfs but this function seems to work ok just for 1 dimension ranges (not tables). So I create the macro:
Function LiczWarunki(Zakr1 As Range, Str1 As Variant, Zakr2 As Range, Str2 As Variant) As Variant
Dim Element1 As Variant
Dim Element2 As Variant
Dim i, l As Integer
Dim FoundMatch1, FoundMatch2 As Boolean
Dim Licznik As Integer
Licznik = 0
l = Zakr1.Rows.Count
For i = 1 To l
For Each Element1 In Zakr1.Rows(i)
FoundMatch1 = False
If Element1 = Str1 Then
FoundMatch1 = True
Exit For
End If
Next Element1
For Each Element2 In Zakr2.Rows(i)
FoundMatch2 = False
If Element2 = Str2 Then
FoundMatch2 = True
Exit For
End If
Next Element2
If FoundMatch1 = True And FoundMatch2 = True Then
Licznik = Licznik + 1
End If
Next i
LiczWarunki = Licznik
End Function
I don't know why I get the #ARG! after using the macro (for example: =LiczWarunki(E2:M26;"posibility2forquestion1";N2:S26;"posibility5forquestion2").
Do you see any mistakes?
Thank you for help.
Bookmarks