+ Reply to Thread
Results 1 to 5 of 5

Sub is skipping lines of code after Then statement

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    USA, Michigan
    MS-Off Ver
    Microsoft Office 2011:Mac
    Posts
    3

    Sub is skipping lines of code after Then statement

    I am just learning how to use user forms, macros and user defined functions and I have ran into a brick wall. I'm trying to execute an If Then statement and even though the conditions are met the lines of code after "Then" are skipped. Here is the macro and the function I'm trying to use. The function works fine, but the sub will not run multiple actions after "Then". I can get it to run one action by putting it on the same line as "If" and "Then", but as soon as I put the code on the next line it just gets skipped. All variables reference input boxes on a user form. By the way I'm on a Mac using Excel:Mac 2011

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    trigcalcscreenshot.jpg
    Last edited by chavez982; 12-05-2012 at 09:53 PM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Sub is skipping lines of code after Then statement

    try the following change in your IF statement:
    Please Login or Register  to view this content.
    The caracter & in VBA is uused to concatenate.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    12-05-2012
    Location
    USA, Michigan
    MS-Off Ver
    Microsoft Office 2011:Mac
    Posts
    3

    Re: Sub is skipping lines of code after Then statement

    It didn't work. I've attached a screen shot of the user form with the values that I'm trying to use to my previous post. Do you have any other suggestions? Maybe its because I'm using a Mac. I should try this on my PC.

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Sub is skipping lines of code after Then statement

    Ok, I think it is because you are using sideA and sideB name in your macro but you have to refer to the textbox of your userform instead. sideA and sideB are just labels you created. It should be something like:
    Please Login or Register  to view this content.
    Use the name of your userform and the name of your texboxes.

    Same thing for sideC in your code.

  5. #5
    Registered User
    Join Date
    12-05-2012
    Location
    USA, Michigan
    MS-Off Ver
    Microsoft Office 2011:Mac
    Posts
    3

    Re: Sub is skipping lines of code after Then statement

    I figured it out. It was because I was trying to do it on a Mac. I just loaded the same file into my PC and it worked just fine. I guess I'll be working on my PC from now on. Thank you for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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