+ Reply to Thread
Results 1 to 7 of 7

I am getting an error "else with out if

  1. #1
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    I am getting an error "else with out if

    hi,
    in below code i am getting an error " compile error " else without if

    Please Login or Register  to view this content.
    Use Code-Tags for showing your code :
    Please mark your question Solved if there has been offered a solution that works fine for you
    If You like solutions provided by anyone, feel free to add reputation using STAR *

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: I am getting an error "else with out if

    The red Else code block doesn't have an If statement. I don't know what you want, so I can't fix it.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: I am getting an error "else with out if

    Hi,

    The error means what it says- you have an Else statement but you have already closed all the If clauses. Properly indenting your code would make it more obvious to you.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: I am getting an error "else with out if

    hi,
    actually i did
    This else i was using with
    Please Login or Register  to view this content.
    then
    Please Login or Register  to view this content.
    else

    Please Login or Register  to view this content.
    thank you for the reply

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: I am getting an error "else with out if

    actually i did
    No, you didn't - you think you did - what you think and what the code says are 2 different things.

    If you took the time to correctly indent the code as AlphaFrog did, and xlNitWit mentioned, then errors like this are obvious. You can find free utilities online to indent.

  6. #6
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: I am getting an error "else with out if

    Found the error
    the red "end if" were in the wrong position
    thank you all of you
    Please Login or Register  to view this content.

  7. #7
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: I am getting an error "else with out if

    Therefore it is so important to indent your code so you can easily follow which If's and End If's belong together.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Choice between "Compile Error" and "Error 91 - Object Variable Not Defined"
    By JoeVanGeaux in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-09-2017, 02:56 PM
  2. Replies: 35
    Last Post: 01-13-2016, 02:16 AM
  3. Replies: 4
    Last Post: 11-13-2015, 09:03 PM
  4. = EMBED("Forms.ComboBox.1","") error "Reference not valid."
    By CatharinaCatharina in forum Excel General
    Replies: 2
    Last Post: 12-11-2014, 09:58 AM
  5. [SOLVED] If Not ActiveSheet.Range("A1").Value Like "apple" Then MsgBox "Error"
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-18-2014, 02:16 PM
  6. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM
  7. [SOLVED] What is Error "Method "Paste" of object "_Worksheet" failed?
    By vat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2006, 04:10 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1