ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CELL CHANGE EVENT (https://www.excelbanter.com/excel-programming/324462-cell-change-event.html)

dan

CELL CHANGE EVENT
 
Hello. I'm trying to figure out how to run a function when data in a
particular cell changes. What's the change handler I would use for that?
Thanks.

Oliver Ferns via OfficeKB.com

CELL CHANGE EVENT
 
Hi,
it depends how the cell value is changed. if it is by user interaction then
the Worksheet_Change event will suffice..

Private Sub Worksheet_Change(ByVal Target As Range)
If target.Address = "$A$1" then
....your code

End If
End Sub

However, there are certain things that do not fire this event. For example
when a linked cell from a Forms Listbox changes this does not fire this
event...

Hth,
Oli

--
Message posted via http://www.officekb.com

Simon Shaw[_5_]

CELL CHANGE EVENT
 
Hi Dan,

you can write a macro inside a sub for the sheet in question using:

Private Sub Worksheet_Change(ByVal Target As Range)

....macro to run when there is a change....

End Sub

Note: this will run regardless of which cell changes, so you may want to run
a check against the cell that is changing to see if the macro should be run.

Simon


"Dan" wrote:

Hello. I'm trying to figure out how to run a function when data in a
particular cell changes. What's the change handler I would use for that?
Thanks.


Bob Phillips[_6_]

CELL CHANGE EVENT
 
Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:H10")) Is Nothing Then
With Target
'do your stuff
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dan" wrote in message
...
Hello. I'm trying to figure out how to run a function when data in a
particular cell changes. What's the change handler I would use for that?
Thanks.





All times are GMT +1. The time now is 09:14 AM.

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