When using a
If Then
'Do Something
Else If
'Do Something
End If
If the first and second condition is true would it execute just the first or both?
for some reason when i have this code:
Dim Report As String
If (DateRange_Pro_TotalCount > 0) Then
Dim DateRange_Pro_ReportStr As String
DateRange_Pro_ReportStr = "Total Referrals: " & DateRange_Pro_TotalCount & vbNewLine _
Report = Report & DateRange_Pro_ReportStr
ElseIf (DateRange_InPro_TotalCount > 0) Then
Dim DateRange_InPro_ReportStr As String
DateRange_InPro_ReportStr = "Total Referrals: " & DateRange_InPro_TotalCount & vbNewLine _
Report = Report & DateRange_InPro_ReportStr
End If
'next statement prints report variable to textBox
This statement only executes the first condition even though both conditions are true. I changed ‘Else If’ to ‘End If’ and ‘If’ ( two diff. conditional statments instead of one statement with two conditions) and it worked.
Yes, you are correct, it will only execute the first block
From IF-THEN-ELSE Statement (VBA)