By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,490 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,490 IT Pros & Developers. It's quick & easy.

If else end if mismatch error--"else without if"

P: 48
Hi All,
I am trying to write a macro with VB editor in excel. However when i try to compile my code i get an error saying "ELSE WITHOUT IF"

My code goes like this
Expand|Select|Wrap|Line Numbers
  1.         If name = name1 Then
  2.                 If activity <> activity1 Then GoTo 10
  3.                     If subactivity <> subactivity1 Then
  4.                             GoTo 10
  5.                     Else
  6.                         GoTo 99
  7.                     End If
  8.                 Else
  9.                     GoTo 99
  10.                 End If
  11.        End If
  12.  
Nov 1 '11 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,679
  1. What's causing the Error is incorrect Syntax on Code Line# 2.
  2. Your Overall Logic appears to be flawed.
  3. My best guess as to what you are trying to accomplish would be:
    Expand|Select|Wrap|Line Numbers
    1. If Name = name1 Then
    2.   If activity <> activity1 Then
    3.     If subactivity <> subactivity1 Then
    4.       GoTo 10
    5.     Else
    6.       GoTo 99
    7.     End If
    8.   Else
    9.     GoTo 99
    10.   End If
    11. End If
Nov 1 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.