PC Review


Reply
Thread Tools Rate Thread

On Change code

 
 
Patrick C. Simonds
Guest
Posts: n/a
 
      23rd Feb 2008
Is it possible to have code on a specific worksheet, say sheet1, which would
run any time the value in cell A4 (and only cell A4) were to change?

 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      23rd Feb 2008
You could use the following On Change event. Right click on the sheet tab
name, select view code and past the code into the VBA editor. cCose the
editor by clicking on the X in the top right corner of the screen.

Unfortunately, if you change like to like (say change 5 to 5) then the code
still runs. It does not recognise whether there is a real change in the
value; only that you have edited the cell. I don't know of any simple way of
saving the old value to test whether there is a real change or only edited
with the same value. It is possible to have a copy of the worksheet if this
is essential.

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$4" Then
MsgBox "Address of current cell is " & Target.Address
'Insert the required code in lieu of the msgbox.
End If

End Sub


--
Regards,

OssieMac


"Patrick C. Simonds" wrote:

> Is it possible to have code on a specific worksheet, say sheet1, which would
> run any time the value in cell A4 (and only cell A4) were to change?
>
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      23rd Feb 2008
Is the change in A4 due to a formula in A4?

Private Sub Worksheet_Calculate()
On Error GoTo stoppit
Application.EnableEvents = False
With Me.Range("A4")
If .Value <> "" Then
MsgBox "Please be advised that A1 value changed."
End If
End With
stoppit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP

On Fri, 22 Feb 2008 21:24:59 -0800, "Patrick C. Simonds" <(E-Mail Removed)>
wrote:

>Is it possible to have code on a specific worksheet, say sheet1, which would
>run any time the value in cell A4 (and only cell A4) were to change?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does ker_01 Microsoft Excel Programming 6 3rd Oct 2008 09:45 PM
Code to change code in a sheet and workbook module Otto Moehrbach Microsoft Excel Programming 11 11th Nov 2007 07:20 PM
Code Conflicts With Worksheet Change Code =?Utf-8?B?UGFpZ2U=?= Microsoft Excel Programming 3 3rd Mar 2006 04:25 PM
re: How to change grey code to change a DRW results column to a currency value Jim Buyens Microsoft Frontpage 0 25th May 2004 05:24 PM
how do I dynamically change an html meta tag from my code behind code? ntm Microsoft ASP .NET 2 19th Jan 2004 05:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:38 PM.