Option Explicit
'advanced
Private Sub CommandButton1_Click()
Dim sh As Worksheet
Set sh = Sheets("Sheet1")
Dim cust_name, addr1, city_name, Error_msg As String
cust_name = Len(sh.Range("C3"))
addr1 = Len(sh.Range("c4"))
city_name = Len(sh.Range("c5"))
If cust_name = 0 Then
Error_msg = ">> PLEASE ENTER CUSTOMER NAME !"
End If
If addr1 = 0 Then
Error_msg = Error_msg & vbNewLine & ">> PLEASE ENTER ADDRESS !"
End If
If city_name = 0 Then
Error_msg = Error_msg & vbNewLine & ">> PLEASE ENTER CITY !"
End If
If Error_msg <> "" Then
MSGBOX Error_msg, vbOKOnly, Title:="IMPORTANT NOTICE !"
Exit Sub
End If
End Sub
' normal
Private Sub CommandButton2_Click()
Dim sh As Worksheet
Set sh = Sheets("Sheet1")
If sh.Range("C3").Value = "" Then
MSGBOX ">> Please Enter Customer Name !"
End If
If sh.Range("C4").Value = "" Then
MSGBOX ">> Please Enter Address !"
End If
If sh.Range("C3").Value = "" Then
MSGBOX ">> Please Enter City !"
End If
End Sub
No comments:
Post a Comment