Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Location
    London
    Posts
    341

    Unanswered: Problem with ElseIf

    Hi all,

    I'm having a problem using an ElseIf statement and I don't understand what the problem is.

    Code:
    If Wsheet.Name = "C1" Then StrMailTo = group1
       ElseIf Wsheet.Name = "C2" Then StrMailTo = group2
       ElseIf Wsheet.Name = "C3" Then StrMailTo = group3
       ElseIf Wsheet.Name = "C4" Then StrMailTo = group4
       Else: StrMailTo = "!!!"
    End If
    Once the sub is in progress, it highlights the second line of the above providing a Compile Error which says that there is an ELSE without an IF

    What am I doing wrong?

    Christy

  2. #2
    Join Date
    Oct 2003
    Location
    London
    Posts
    341
    Never mind... I fixed it just by moving the result to the next line i.e.

    Code:
    If Wsheet.Name = "C1" Then 
          StrMailTo = group1
       ElseIf Wsheet.Name = "C2" Then 
          StrMailTo = group2
       ElseIf Wsheet.Name = "C3" Then 
          StrMailTo = group3
       ElseIf Wsheet.Name = "C4" Then 
          StrMailTo = group4
       Else
          StrMailTo = "!!!"
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •