View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
AM AM is offline
external usenet poster
 
Posts: 41
Default Compare cell and msg

Thanks, This is exactly what I needed and it works. Appreciate everyones help.

AM

"JLGWhiz" wrote:

However, if your project needs to use code. Try the macro below. If needs
to be pasted into the worksheet code window. Right click the sheet tab and
select View Code from the drop down menu. Copy this code and paste it into
the code window.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("B2") Then
If Range("B2") < Range("A2") Then
MsgBox "CELL B2 CANNOT BE LESS THAN CELL A2, TRY AGAIN"
Range("B2").Select
End If
End If
End Sub




"AM" wrote:

Hi All,

I need some help woth code.
On cell B2 when focus is lost then compare its value with the value of A2,
if b2 value is less then A2 then I want to popup a message saying value in B2
cannot be less then A2 and bring the focus back on B2

Thank In Advance
AM