none
Nested If then Else Statement RRS feed

  • Question

  • Hi,

    Please can somebody tell me if 'If' Statements can be nested within each other?  Is the following syntax valid:

    If textbox1.value = 1 then

                    If texbox2.value = 1 then

                    Region = “South”

    Elseif textbox2.value = 2 then

    Region = “North

                    End if

    Elseif textbox1.value = 2 then

                    If textbox3.value = 4 then

                    Region = “North”

                    Elseif textbox3.value = 5 then

                    Region = “South”

    End if

    Thanks



    Tuesday, December 8, 2015 9:55 PM

Answers

  • Yes, you can, but I think you're missing one more End If at the end of your code block. You just have to make sure each If/ElseIf/Then has a matching End If. Hope that helps...
    • Marked as answer by system243trd Tuesday, December 8, 2015 10:20 PM
    Tuesday, December 8, 2015 9:59 PM