+ Reply to Thread
Results 1 to 5 of 5

ElseIf does not work? Please help :(

  1. #1
    Registered User
    Join Date
    09-23-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    9

    ElseIf does not work? Please help :(

    I have been assign to create a macros on converting bearings to angles

    The linear equation is angle = m * bearing + b
    m stays the same for all bearings but b changes
    as shown in the following code

    Please Login or Register  to view this content.

    I have put in that if the bearing given is between 270 to 360, then it uses a different value for b

    But on my side, it seems to continue to use my first calculations for all bearings
    Why is that (( ?

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: ElseIf does not work? Please help :(

    Your syntax is wrong, you need And:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-23-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    9

    Re: ElseIf does not work? Please help :(

    Quote Originally Posted by kyle123 View Post
    your syntax is wrong, you need and:

    Please Login or Register  to view this content.


    omg i love you please

    thank you very much!!!!!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: ElseIf does not work? Please help :(

    You can't do the comparison the way you have. You need to use And.

    Please Login or Register  to view this content.
    Not sure you strictly need ElseIf. You can probably get away with just Else (and drop the extra compariosns)


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Contributor
    Join Date
    05-27-2014
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    2007 & 2010
    Posts
    273

    Re: ElseIf does not work? Please help :(

    Quote Originally Posted by mrcropse425 View Post
    I have been assign to create a macros on converting bearings to angles

    The linear equation is angle = m * bearing + b
    m stays the same for all bearings but b changes
    as shown in the following code

    Please Login or Register  to view this content.

    I have put in that if the bearing given is between 270 to 360, then it uses a different value for b

    But on my side, it seems to continue to use my first calculations for all bearings
    Why is that (( ?
    Try this:
    Please Login or Register  to view this content.
    It's worth noting that the function would return 0 if aa is less than 0 or greater than 360
    Last edited by kadeo; 09-25-2015 at 06:35 AM.
    Please click *Add Reputation if I've helped

+ 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. If / ElseIf within For Each?
    By pwells in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-26-2014, 10:35 AM
  2. Code stepping in to elseif statement when elseif is definitely not true
    By DFrank231 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-13-2013, 05:31 PM
  3. ElseIF does not work
    By Ziad Homaidan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2012, 07:41 AM
  4. If Elseif elseif problem
    By tjbillund in forum Excel General
    Replies: 3
    Last Post: 08-10-2011, 07:02 AM
  5. [SOLVED] if elseif
    By flow23 in forum Excel General
    Replies: 0
    Last Post: 11-14-2005, 10:15 AM
  6. [SOLVED] Re: IF..Then..ELSE.. ELSEIF
    By rjamison in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-13-2005, 08:05 PM
  7. [SOLVED] If, ElseIf
    By mast in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-26-2005, 09:06 AM

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