Results 1 to 5 of 5

Sub is skipping lines of code after Then statement

Threaded View

  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

    Private Sub cmdOK_Click()
        
    If sideA > 0 & sideB > 0 Then
        angleA = AtnDegrees(sideA, sideB)
        angleB = 90 - AtnDegrees(sideA, sideB)
        sideC = Sqr(sideA ^ 2 + sideB ^ 2)
    Else
    End If
    
    End Sub
    Function AtnDegrees(side1, side2)
    
    If side1 < 0 Or side2 < 0 Then MsgBox "Must be a number greater than 0"
    If side1 <= side2 Then AtnDegrees = Atn(side1 / side2) * (180 / Application.Pi())
    If side1 > side2 Then AtnDegrees = Atn(side2 / side1) * (180 / Application.Pi())
    
    End Function
    trigcalcscreenshot.jpg
    Last edited by chavez982; 12-05-2012 at 09:53 PM.

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