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
Bookmarks