PDA

View Full Version : Solved: Another Problem



Killer Bud
05-13-2010, 05:50 PM
I have another one guys.
Please see the following code. Everything I want to do works flawlessly, except for 1 thing. If I pick from combo box 2 and leave combo box 3 empty, I get my msgbox " You must enter a material" upon hitting the OK button. The problem is, the code doesn't stop and let me choose a material. The next msgbox opens and says " Would you like to price another gasket?"

Question is, how to I get the code to stop as soon as it reaches this error and wait for proper input before proceeding completely?

Thanks Gents,


Public Sub OkButton_Click()
If ComboBox2.Text = "" Then MsgBox " You Must Enter A Material"
If ComboBox3.Text = "" Then MsgBox " You Must Enter A Thickness"
On Error Resume Next
MsgBox "Total Sell Cost of Gasket is $" & Range("c25")
If MsgBox("Would you like to price another gasket?", vbYesNo) = vbYes Then
Call UserForm1.Show
Else
ActiveWorkbook.Close savechanges:=False
End If


End Sub

tpoynton
05-13-2010, 05:59 PM
just have to exit the sub...

Public Sub OkButton_Click()
If ComboBox2.Text = "" Then
MsgBox " You Must Enter A Material"
Exit Sub
End If
If ComboBox3.Text = "" Then
MsgBox " You Must Enter A Thickness"
Exit Sub
End If
On Error Resume Next
MsgBox "Total Sell Cost of Gasket is $" & Range("c25")
If MsgBox("Would you like to price another gasket?", vbYesNo) = vbYes Then
Call UserForm1.Show
Else
ActiveWorkbook.Close savechanges:=False
End If


End Sub

Killer Bud
05-13-2010, 06:11 PM
Thank you so much.....seems to be so much easier than what I've been trying lol. Thanks again,