Need to exit sub if user clicks cancel.
If I change the variables to strings it will work. However I need the variables to be doubles.
'Declare Variables
Dim NumberOfLocations As Double
Dim isValid As Boolean
Dim FirstLocation As Double
Dim SecondLocation As Double
Sub CalculateLineShare()
' Making sure the boolean variable is set to false
isValid = False
'start of loop to make sure user puts in an integer
Do Until isValid = True
NumberOfLocations = InputBox("Enter Number of Locations", "Enter Number")
' right here is where the problem is at if the variables are strings and the user clicks cancel every thing works.
If NumberOfLocations = "" Then
Exit Sub
End If
If IsNumeric(NumberOfLocations) Then
isValid = True
Else
MsgBox "You must enter an Integer to continue"
End If
Loop
If NumberOfLocations <= 2 Then
FirstLocation = InputBox("Enter Number of Pieces used at first location", "Enter Number")
SecondLocation = InputBox("Enter Number of Pieces used at Second location", "Enter Number")
Else
End If
End Sub