[color #ff0000]Problems with IF.. .Then
[color #ff0000]Problems with IF.. .Then
(OP)
Below is the program tied to a userform in EXCEL. The userform is used to get the desired clearence below a powerline and the place from the lowest pole where the desired clearance will be calculated. The problem is that the span is 25 meters long and I can't calculate the clearance at the these places (from 3 to 9 meters from the lowest pole) because the following message comes:
"The Distance from the Lowest Pole where the Sag will be Calculated shall be Smaller than or Equal to " & Worksheets("TSag Net").range("e3"), _
vbInformation, "Check"
Of course I have checked the value in Worksheets("TSag Net").range("e3") and this is the correct one -- "25".
I have no idea why this is occuring... Any help will be very usefull. Thank you for the help you can give me.
Private Sub Calculate_Click()
TodoLlenoTension = 0
If IsNumeric(TensionSag) = False Then
MsgBox "Check the Desired Sag.", _
vbInformation, "Check"
ElseIf TensionSag < 0 Then
MsgBox "The Sag Value shall be Positive.", _
vbInformation, "Check"
ElseIf TensionDistance <> "At the Lowest Point" And _
IsNumeric(TensionDistance) = False Then
MsgBox "Check the Distance from the Lowest Pole where the Sag will be Calculated.", _
vbInformation, "Check"
ElseIf IsNumeric(TensionDistance) = True And TensionDistance < 0 Then
MsgBox "The Distance from the Lowest Pole to the Sag shall be Positive.", _
vbInformation, "Check"
ElseIf IsNumeric(TensionDistance) = True And TensionDistance > Worksheets("TSag Net").range("e3") Then
MsgBox "The Distance from the Lowest Pole where the Sag will be Calculated shall be Smaller than or Equal to " & Worksheets("TSag Net").range("e3"), _
vbInformation, "Check"
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Else: TodoLlenoTension = 1
End If
If TodoLlenoTension = 1 Then
Me.Hide
StartTime = Timer
Worksheets("PoleData").Cells(2, 10) = TensionSag
Worksheets("(TSag)2").Activate
'XXXXXX COTEJA AQUI XXXXXX
If TensionDistance <> "At the Lowest Point" Then
Worksheets("(TSag)2").range("ap30") = TensionDistance * 3.28
Sheet6.Iterating_For_ClearanceB
Else
Worksheets("(TSag)2").range("ap30") = ""
Sheet6.Iterating_For_Clearance
End If
'XXXXXX COTEJA AQUĆ XXXXXX
EndTime = Timer
Worksheets("(TSag)2").range("ar30") = Format(EndTime - StartTime, "0.0")
Tension.Caption = Worksheets("(TSag)2").range("x15") & " Lbs"
ElapsedTime.Caption = Worksheets("(TSag)2").range("ar30") & " segs"
UserFormTension.Show
End If
End Sub
"The Distance from the Lowest Pole where the Sag will be Calculated shall be Smaller than or Equal to " & Worksheets("TSag Net").range("e3"), _
vbInformation, "Check"
Of course I have checked the value in Worksheets("TSag Net").range("e3") and this is the correct one -- "25".
I have no idea why this is occuring... Any help will be very usefull. Thank you for the help you can give me.
Private Sub Calculate_Click()
TodoLlenoTension = 0
If IsNumeric(TensionSag) = False Then
MsgBox "Check the Desired Sag.", _
vbInformation, "Check"
ElseIf TensionSag < 0 Then
MsgBox "The Sag Value shall be Positive.", _
vbInformation, "Check"
ElseIf TensionDistance <> "At the Lowest Point" And _
IsNumeric(TensionDistance) = False Then
MsgBox "Check the Distance from the Lowest Pole where the Sag will be Calculated.", _
vbInformation, "Check"
ElseIf IsNumeric(TensionDistance) = True And TensionDistance < 0 Then
MsgBox "The Distance from the Lowest Pole to the Sag shall be Positive.", _
vbInformation, "Check"
ElseIf IsNumeric(TensionDistance) = True And TensionDistance > Worksheets("TSag Net").range("e3") Then
MsgBox "The Distance from the Lowest Pole where the Sag will be Calculated shall be Smaller than or Equal to " & Worksheets("TSag Net").range("e3"), _
vbInformation, "Check"
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Else: TodoLlenoTension = 1
End If
If TodoLlenoTension = 1 Then
Me.Hide
StartTime = Timer
Worksheets("PoleData").Cells(2, 10) = TensionSag
Worksheets("(TSag)2").Activate
'XXXXXX COTEJA AQUI XXXXXX
If TensionDistance <> "At the Lowest Point" Then
Worksheets("(TSag)2").range("ap30") = TensionDistance * 3.28
Sheet6.Iterating_For_ClearanceB
Else
Worksheets("(TSag)2").range("ap30") = ""
Sheet6.Iterating_For_Clearance
End If
'XXXXXX COTEJA AQUĆ XXXXXX
EndTime = Timer
Worksheets("(TSag)2").range("ar30") = Format(EndTime - StartTime, "0.0")
Tension.Caption = Worksheets("(TSag)2").range("x15") & " Lbs"
ElapsedTime.Caption = Worksheets("(TSag)2").range("ar30") & " segs"
UserFormTension.Show
End If
End Sub





RE: [color #ff0000]Problems with IF.. .Then
I notice this is a second posting of this question, with no replies to your original post. I would be happy to take a look at this workbook if this is OK with you. If so, be sure the data producing the problem is in place, and send to me at rmikesmith@earthlink.net
Regards,
Mike
RE: [color #ff0000]Problems with IF.. .Then
Thanks for requesting my posting, but I have already fixed the problem... It should be a "bug" in EXCEL. Everything is Bullet Proof until the gun fires!!