I'd like to get some help with the following code. I am very new to this but I think it's an easy solution I'm just unable to retrofit suggestions from other searches into my code.
The msgboxes are working fine on the first pass to check if the text box values are correct but when I am checking to see if a formula result from a sheet is correct I'm getting 5 message boxes popping up.
Hope this makes sense, let me know if you have any suggestions!
`Private Sub SpeedCommand_Click()
Dim ctl As Control
If TextBox1AM180.Value > 12000 And TextBox1AM180.Value <> "" Then
MsgBox "Rate Value is out of range for this boom. Ensure rate value is less than 12,000 lbs./acre", vbExclamation, "Main Bin Application Rate"
Me.TextBox1AM180.SetFocus
Exit Sub
End If
If (TextBox2AM180.Value > 120 Or TextBox2AM180.Value < 20) And TextBox2AM180.Value <> "" Then
MsgBox "Density Value is out of range. Ensure density value is between 20 and 120 lbs./cu ft.", vbExclamation, "Main Bin Density"
Me.TextBox2AM180.SetFocus
Exit Sub
End If
If TextBox3AM180.Value > 12000 And TextBox3AM180.Value <> "" Then
MsgBox "Rate Value is out of range for this boom. Ensure rate value is less than 12,000 lbs./acre", vbExclamation, "Granular Bin Application Rate"
Me.TextBox3AM180.SetFocus
Exit Sub
End If
If (TextBox4AM180.Value > 120 Or TextBox4AM180.Value < 20) And TextBox4AM180.Value <> "" Then
MsgBox "Density Value is out of range. Ensure density value is between 20 and 120 lbs./cu ft.", vbExclamation, "Granular Bin Density"
Me.TextBox4AM180.SetFocus
Exit Sub
End If
' Write data to worksheet
With Range("B4")
.Offset(0, 0).Value = Me.TextBox1AM180.Value
.Offset(1, 0).Value = Me.TextBox2AM180.Value
.Offset(5, 0).Value = Me.TextBox3AM180.Value
.Offset(6, 0).Value = Me.TextBox4AM180.Value
End With
If Range("MaxSpeed1").Value > 30 Then
MsgBox "Based upon rate and density, speed is restricted by machine top end application speed."
Exit Sub
End If
If Range("MaxSpeed2").Value > 30 Then
MsgBox "Based upon rate and density, speed is restricted by machine top end application speed."
Exit Sub
End If
' Hide the form
frmAirmax.Hide