Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
VBA syntax question
I am using the following to automatically run a particular code (xyz)
if a cell (A1) becomes 10. Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Application.Intersect(Target, Range("A1")) Is Nothing Then If Target.Value 10 Then MsgBox "xyz" End If End If End Sub What if I want "xyz" to run not just if cell A1 10 but if A2 10 as well? Or better yet, for each value in the entire range A:A that 10, the code xyz will run. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
VBA syntax question
On 5 Dec, 14:56, Matt wrote:
I am using the following to automatically run a particular code (xyz) if a cell (A1) becomes 10. Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Application.Intersect(Target, Range("A1")) Is Nothing Then If Target.Value 10 Then MsgBox "xyz" End If End If End Sub What if I want "xyz" to run not just if cell A1 10 but if A2 10 as well? Or better yet, for each value in the entire range A:A that 10, the code xyz will run. Adjust the range to the following Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Application.Intersect(Target, Range("A:A")) Is Nothing Then If Target.Value 10 Then MsgBox "xyz" End If End If End Sub Steve |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
VBA syntax question
Perhaps
Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Intersect(Target, Range("A:A")) Is Nothing Then If Target.Value 10 Then MsgBox "xyz" End If End If End Sub Mike "Matt" wrote: I am using the following to automatically run a particular code (xyz) if a cell (A1) becomes 10. Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Application.Intersect(Target, Range("A1")) Is Nothing Then If Target.Value 10 Then MsgBox "xyz" End If End If End Sub What if I want "xyz" to run not just if cell A1 10 but if A2 10 as well? Or better yet, for each value in the entire range A:A that 10, the code xyz will run. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
question about syntax in a simple macro... | Excel Discussion (Misc queries) | |||
syntax question | Excel Worksheet Functions | |||
BringToFront syntax question | Charts and Charting in Excel | |||
Data Validation Syntax Question | Excel Discussion (Misc queries) | |||
syntax question - cell references in VB code | New Users to Excel |