ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change Event Problem (https://www.excelbanter.com/excel-programming/350117-change-event-problem.html)

mastermind

Change Event Problem
 
I am trying to write a change event that works on a particular range
and ONLY fires when the initial cell value is NOT " ". I have managed,
through trial and error, to write an event that will work over a range,
but cannot seem to get it to fire when I want to. It either fires all
of the time or not at all. Any help would be greatly appreciated


Ron de Bruin

Change Event Problem
 
Try this for A1:A10

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1:A10"), Target) Is Nothing Then
If Target.Value = "NOT" Then
MsgBox "YourCode or YourMacroName"
End If
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"mastermind" wrote in message oups.com...
I am trying to write a change event that works on a particular range
and ONLY fires when the initial cell value is NOT " ". I have managed,
through trial and error, to write an event that will work over a range,
but cannot seem to get it to fire when I want to. It either fires all
of the time or not at all. Any help would be greatly appreciated




mastermind

Change Event Problem
 
That isn't quite what I was looking for. I need the macro to fire
every time except when the initial value of the cell is " " (nothing).
When the user opens the sheet for the first time it will be blank.
They will then populate certain fields with data. I don't want the
macro to fire while they are inputing the information...only if they
decide to go back and change something they have already answered. I
hope that is clearer. I don't know how else to explain it.


Ron de Bruin

Change Event Problem
 
Try this

Public Emp As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Range("A1:A10"), Target) Is Nothing Then
If Emp < True Then
MsgBox "YourCode or YourMacroName"
End If
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Emp = False
If Not Application.Intersect(Range("A1:A10"), Target) Is Nothing Then
If Target.Value = "" Then Emp = True
End If
End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl


"mastermind" wrote in message oups.com...
That isn't quite what I was looking for. I need the macro to fire
every time except when the initial value of the cell is " " (nothing).
When the user opens the sheet for the first time it will be blank.
They will then populate certain fields with data. I don't want the
macro to fire while they are inputing the information...only if they
decide to go back and change something they have already answered. I
hope that is clearer. I don't know how else to explain it.





All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com