View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Paige Paige is offline
external usenet poster
 
Posts: 270
Default Checking to See if Range Values Add up to 100

Thanks guys - the revised code works perfectly!!!!

"Paige" wrote:

I have 2 cells (A1.A2) where numbers will be entered.
Once the user goes to cell A3, I need VBA code to check
to ensure that A1+A2 = 100, and if they do not, to show
an error message saying they do not (I know how to do the
messagebox, but when I go to Cell A3, nothing happens even tho A1+A2 does
not = 100). What I have so far is the following (which is in the specific
worksheet code window):

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "A3" Then
If Range("A1").Value + Range("A2").Value <100 Then
MsgBox ("Error")
End If
End If
End Sub

I need code for this, not data validation or formuals. Thanks for any help
you can provide....pc