+ Reply to Thread
Results 1 to 8 of 8

Else Without If Issue

  1. #1
    Registered User
    Join Date
    05-25-2017
    Location
    Chicago
    MS-Off Ver
    Office 2016
    Posts
    31

    Question Else Without If Issue

    Hello Everyone!

    I'm getting an "Else Without If" error on my macro. I'm trying to autogenerate some emails based on the value of the cell H21 in my spreadsheet.
    It looks complex because of the outapp and outmail stuff, but it's really just an "if-then, elseif-then, else" statement. Can anyone spot what I'm getting wrong?


    Please Login or Register  to view this content.

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Else Without If Issue

    Hi wtucker- You can't use a single End With like that. You have to close out each With Block separately, within the IF..Else clause where it's begun.
    Please Login or Register  to view this content.
    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Else Without If Issue

    Hello wtucker,

    Try your code as shown below:

    Please Login or Register  to view this content.
    Regards.
    Last edited by Winon; 08-07-2017 at 03:48 PM. Reason: Spelling
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Else Without If Issue

    You have a "With" with out an "End With" inside you If .... ElseIf statement
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  5. #5
    Registered User
    Join Date
    05-25-2017
    Location
    Chicago
    MS-Off Ver
    Office 2016
    Posts
    31

    Re: Else Without If Issue

    Quote Originally Posted by leelnich View Post
    Hi wtucker- You can't use a single End With like that. You have to close out each With Block separately, within the IF..Else clause where it's begun.
    So simple. Thank you! I don't know why I couldn't see that.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Else Without If Issue

    Hi wtucker,

    I "played" with your code a little:

    Please Login or Register  to view this content.
    Last edited by xladept; 08-07-2017 at 07:08 PM. Reason: Bakerman correction
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  7. #7
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Else Without If Issue

    You're most welcome! We ALL overlook the obvious occasionally, that's half the threads on this site! Well, OK, not HALF, but a LOT!
    If that answers your original question, please go to Thread Tools up top and mark your thread as SOLVED. Thanks -Lee

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee

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

    Re: Else Without If Issue

    @ Orrin

    Also template needs to be of certain plantype.

    Please Login or Register  to view this content.
    Last edited by bakerman2; 08-07-2017 at 07:08 PM.
    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. Lookup Formula Issue, Search issue
    By kperitz in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-07-2014, 01:50 PM
  2. Replies: 1
    Last Post: 08-29-2013, 07:29 AM
  3. [SOLVED] Insert shift down issue macro issue
    By CC64 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-15-2012, 10:57 PM
  4. Issue with X axis values NOT graphing on Scatter graph and issue with Labels
    By lmausolf in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2012, 07:20 AM
  5. Issue - Image button issue - by JBeaucaire
    By Vaibhav in forum Suggestions for Improvement
    Replies: 2
    Last Post: 05-06-2012, 07:35 AM
  6. [SOLVED] Issue - Attachment issue - by Simon Lloyd
    By Vaibhav in forum Suggestions for Improvement
    Replies: 16
    Last Post: 03-16-2012, 06:56 PM
  7. [SOLVED] Issue -Joke thread issue - Mordred
    By Vaibhav in forum Suggestions for Improvement
    Replies: 2
    Last Post: 02-17-2012, 01:31 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