Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8613717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:57:03+00:00 2026-06-12T04:57:03+00:00

When using a If Then ‘Do Something Else If ‘Do Something End If If

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:57:05+00:00Added an answer on June 12, 2026 at 4:57 am

    Yes, you are correct, it will only execute the first block

    From IF-THEN-ELSE Statement (VBA)

    If condition_1 Then
        result_1
    
     ElseIf condition_2 Then
       result_2
     ...
     ElseIf condition_n Then
        result_n
    
     Else
       result_else
    
     End If
    

    condition_1 to condition_n are evaluated in the order listed. Once a
    condition is found to be true, the IF-THEN-ELSE statement will execute
    the corresponding code and not evaluate the conditions any further.

    result_1 to result_n is the code that is executed once a condition is
    found to be true.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to display some data from a list sharepoint and then using jquery
I did two sample applications in ios.Both applications i have done using storyboard.Then after
Trying to first .getJSON then using that data to become the source of my
I am doing some data conversion(like csv) to xml with SAX then using transformer
I need to write the function product in two ways: Using Guards Using if-then-else
After checking the condition if the condition fails then using request dispatcher iam redirecting
Short of (the obvious) building a C style string first then using that to
I have a database SQLite and then using SimpleCursorAdapter , I display values into
In Java I can do by using an Iterator and then using the .remove()
I have a class that gets a movieClip and then using addChild adds it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.