Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use this Paige
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Range("A3"), Target) Is Nothing Then If Range("A1").Value + Range("A2").Value < 100 Then MsgBox "Error" End If End If End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Paige" wrote in message ... 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If Target.Address = "$A$3" Then
HTH, Gary Brown "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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("A3"), Target) Is Nothing Then If Range("A1").Value + Range("A2").Value < 100 Then MsgBox ("Error") End If End If End Sub Mike F "Paige" wrote in message ... 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Checking on two values | Excel Discussion (Misc queries) | |||
Checking ALL values in a range | Excel Discussion (Misc queries) | |||
Checking Cell Values Row-by-Row | Excel Programming | |||
checking for missing values | Excel Programming | |||
checking values in a cel | Excel Programming |