Reputation: 51
Private Sub ROLparameter_Click()
Line1: RolLow = InputBox("Please enter the lower bound percentage for ROL calculation between 0 and 100 (initially " & RolLow * 100 & "%):")
If Not 0 <= RolLow <= 100 Then GoTo Line1
End If
End Sub
I have user form button, when I press it will enter this sub. The problem is it gives error "end if without if". When I remove end if, it works strangely.
Such as;
it does recognize the RolLow value when user enter 80, as "80". If not directs it to end sub, if i use only "if" then it will direct to line 1 all the time. No checking of the value.
This code working normally in a module.
What can be the problem?
(Variables are defined public before the subs)
(i tried module.variable thing also)
Upvotes: 1
Views: 136
Reputation: 33672
This is the code you are trying to run: if the user inputs a value smaller than 0 or larger than 100, then go back to InputBox
Private Sub ROLparameter_Click()
Line1: Rollow = CLng(InputBox("Please enter the lower bound percentage for ROL calculation between 0 and 100 (initially " & Rollow * 100 & "%):"))
If Not ((0 <= Rollow) And (Rollow <= 100)) Then
GoTo Line1
End If
End Sub
Upvotes: 0