Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default On Change code

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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default On Change code

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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default On Change code

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"
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to change code in a sheet and workbook module Otto Moehrbach Excel Programming 11 November 11th 07 07:20 PM
Change code with code? CLR Excel Programming 2 April 25th 07 07:40 PM
Change code by code. Can you do that? Corey Excel Programming 2 March 1st 07 12:52 AM
Can I use code/macro to change code/macro in an existing file? Scott Bedows Excel Programming 2 February 14th 07 05:50 AM
Code Conflicts With Worksheet Change Code Paige Excel Programming 3 March 3rd 06 04:25 PM


All times are GMT +1. The time now is 02:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"