There are three sheets in my book: Namely; Questions, Answersand Incorrect Mappings.
The Questions Sheet:
Column A- Question_Id.
Column B: Answer_Typematters among: True / False , Friend , Multi item , CheckBoxes , Event .
Column C: Answer_Id(One or more "numeric values"), separated by semicolons.
The Answers Sheet:
Column A Answer_Id. (This will list some or all of the answer identifiers of the sheet Questions, each on the same line).
Column B- Frequency; which has meanings such as:
Event , Annually , Six months , Quarterly .
A question and answer sheet is associated with a column Answer_Id.

Requirement: If any question ID has "Answer Types" such as True / False, One another, Multi item, CheckBoxes; then answer it in a
Answerssheet should not have a frequency Event Basedagainst such an Answer_Id. those. if Answer_Typeis an “event”, then only the frequency against it should be event-based
Incorrect comparisons in the sheet Questionsshould be sent to the sheet Incorrect Mappingsas hyperlinks to the Questions sheet. I wrote the following code:
Dim shname, strstr, strErr, stString As String
Dim stArray() As String
Dim AnsIds1 As Range
Dim celadr, celval, AnsId1, AnsId2, questionType As Variant
Dim LastRow, LastRowSheet2 As Long
LastRow = Sheets("Questions").Cells(Rows.Count, 2).End(xlUp).Row
LastRowSheet2 = Sheets("Answers").Cells(Rows.Count, 2).End(xlUp).Row
For Each questionType In Worksheets("Questions").Range("B2:B" & LastRow)
celadr = questionType.Address
celval = questionType.Value
If Len(celval) >= 1 Then
If InStr(1, ("TRUE/FALSE,ONE ANOTHER,MULTI ITEM,CHECKBOXES,"), UCase(celval) & ",") >= 1 Then
For Each AnsIds1 In Worksheets("Questions").Range("C2:C" & LastRow)
stString = AnsIds1
stArray() = Split(stString, ";")
For Each AnsId1 In stArray()
For Each AnsId2 In Worksheets("Answers").Range("A2:A" & LastRowSheet2).Cells
If Trim(AnsId1) = Trim(AnsId2) Then
If Trim(UCase(AnsId2.Offset(0, 1).Value)) = "EVENT BASED" Then 'Is this If condition should be changed to something else?
AnsIds1.Interior.Color = vbRed
celadr = AnsIds1.Address
Sheets("Questions").Select
shname = ActiveSheet.Name
Sheets("Incorrect Mappings").Range("A65536").End(xlUp).Offset(1, 0).Value = AnsId2 & " Should not have Event based frequency"
strstr = "'" & shname & "'!" & Range(celadr).Address(0, 0)
Sheets("Incorrect Mappings").Hyperlinks.Add Anchor:=Sheets("Incorrect Mappings").Range("A65536").End(xlUp), Address:="", SubAddress:=strstr
End If
End If
Next
Next
Next
End If
End If
Next
When I run the above code, I get mixed output (wrong output).
, , Is this If condition should be changed to something else? .
- , ?
( , , Incorrect Mappings, )