martinargimon
Member
HI There,
Sorry If i did paste the code incorrectly. I am not too sure if you accept the post as is.
I have a problem with the Countif formula ( which is located in the sub on the second blocK).
It does not show the actual MsgBox content " Order Number already exist!.....
Most likely i have the Exit Sub command incorrectly placed right after the MsgBox.
Would you be able to guide me how i should fix this?
Many Thanks
Martin
>>> use code - tags <<<
You can find - how to do this? ... from
..
as well as
Seems You're interesting about VBA Macros,
then this should have opened in there.
(This time, I've moved it there.)
You could reread Forum Rules from here:
Sorry If i did paste the code incorrectly. I am not too sure if you accept the post as is.
I have a problem with the Countif formula ( which is located in the sub on the second blocK).
It does not show the actual MsgBox content " Order Number already exist!.....
Most likely i have the Exit Sub command incorrectly placed right after the MsgBox.
Would you be able to guide me how i should fix this?
Many Thanks
Martin
>>> use code - tags <<<
You can find - how to do this? ... from
Posting a sample workbook
The Chandoo.org Forum now has the facilities to upload files directly into a post. Simply use either the Media icon in the Edit menu or the Upload a File Button next to the Save Changes button Alternatively In the Chandoo.org Blog or here in the Forums you can still upload files using a Free...
chandoo.org
as well as
Seems You're interesting about VBA Macros,
then this should have opened in there.
(This time, I've moved it there.)
You could reread Forum Rules from here:
Site Rules - New Users - Please Read
Hi all, Welcome to the Chandoo.org Forums. Posting Rules & Etiquette The Chandoo.org Forums is a collaborative and happy place to learn and expand your Excel knowledge. The Chandoo.org Forums consist of several Sub-Forums based on the type of question/area of Excel you are interested in...
chandoo.org
Code:
Private Sub CmdBSaveOrder_Click()
If Me.TxtBox_PolicyNumber = "" Or Me.CmbBox_CustomerNo = "" Or Me.CmbBox_PropertyType = "" _
Or Me.CmbBox_TeamNumber = "" Or Me.TxtBox_OrderNo = "" Then
MsgBox "Data Missing! Please complete information"
Exit Sub
End If
If WorksheetFunction.CountIf(Sheets("Orders").Range("B:B"), Me.TxtBox_OrderNo.Value) > 0 Then
MsgBox "Order Number already exist ! . Try a new Number"
Call CmdBNewOrder_Click
Exit Sub
End If
Me.Hide
Application.ScreenUpdating = False
'Collects Data from FORM and loads to 'Calculation-Table'
Range("AB6") = TxtBox_OrderNo.Value
Range("AC6") = DTPicker1.Value
Range("AE6") = TxtBox_PolicyNumber.Value
Range("AF6") = CmbBox_CustomerNo.Value
Range("AI6") = "AMA"
Range("AJ6") = CmbBox_PropertyType.Value
Range("AR6") = CmbBox_TeamNumber.Value
Dim nextBlankRow As Long
lr = Sheets("Orders").Cells(Rows.Count, 2).End(xlUp).Row
nextBlankRow = lr + 1
Range("B" & nextBlankRow) = Range("AB6").Value
Range("C" & nextBlankRow) = Range("AC6").Value
Range("D" & nextBlankRow) = Range("AD6").Value
Range("E" & nextBlankRow) = Range("AE6").Value
Range("F" & nextBlankRow) = Range("AF6").Value
Range("G" & nextBlankRow) = Range("AG6").Value
Range("H" & nextBlankRow) = Range("AH6").Value
Range("I" & nextBlankRow) = Range("AI6").Value
Range("J" & nextBlankRow) = Range("AJ6").Value
Range("K" & nextBlankRow) = Range("AK6").Value
Range("L" & nextBlankRow) = Range("AL6").Value
Range("M" & nextBlankRow) = Range("AM6").Value
Range("N" & nextBlankRow) = Range("AN6").Value
Range("O" & nextBlankRow) = Range("AO6").Value
Range("P" & nextBlankRow) = Range("AP6").Value
Range("Q" & nextBlankRow) = Range("AQ6").Value
Range("R" & nextBlankRow) = Range("AR6").Value
Range("S" & nextBlankRow) = Range("AS6").Value
Range("T" & nextBlankRow) = Range("AT6").Value
Range("B8", Range("B8").End(xlDown)).Sort Key1:=Range("B8"), _
Order1:=xlAscending, Header:=xlYes
Application.ScreenUpdating = True
MsgBox "New Record has been added Succesfully"
Call CmdBNewOrder_Click
Unload Me
End Sub
Last edited by a moderator: