• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Get A Msg Box

Marsdon

New Member
Hi All,

It was nice to be part of Chandoo. Org. I have an question here as I am newbie to VBA.

For Instance:-

Range (A1) has a Date already entered and Range (B1) has another date to be entered. Whenever the Date entered in Range (B1) it should always be greater than Range (A1) if not. I should get an error Msg Box saying that Date entered is not Valid.
 
Hi ,

This can be done without resorting to VBA ; make use of the Data Validation feature ; click on Data -> Data Validation -> Data Validation ; in the Allow drop-down , select Custom , and type in the formula :

=B1>A1

Now , whenever you try entering a date in B1 which is earlier than the date in A1 , an error message will be displayed.
 
HI

I have entered below code of my own

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num1 As Integer
Dim Num2 As Integer

Num1 = Range("G9").Value
Num2 = Range("H9").Value

IF Num2 > Num1

MsgBox "Restricted"

Else

End If

End Sub
 
Back
Top