How to determine if a cell's data has been changed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to automatically record in cell A1 the date that data in Cell A2 was
last changed. I want to simply register any change to data in Cell A2.
Seems a simple task but can't find the relevant function.

Thanks
 
Paste the following macro in worksheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A2"), Target) Is Nothing Then
Exit Sub
End If
Application.EnableEvents = False
Range("A1").Value = Now
Application.EnableEvents = True
End Sub

REMEMBER: worksheet code nat a standard module.
 
Hi

Really appreciate the input. Apologise if follow-on queries a bit basic.

How do I check whether I have worksheet code module? Is there a way to
achieve the funcionality I need without that module?

I actually need to check a range of cells [A0 - An] and Insert the date in
Bx if the Ax has changed. How should I modify the code you provide to
achieve this?

Thanks again

A
 
No need for any apologies. First the update to the code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A:A"), Target) Is Nothing Then
Exit Sub
End If
Application.EnableEvents = False
Target.Offset(0, 1).Value = Now
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

Now try entering material in column A. If you have any concerns, first try
it onl a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3.close the VBE window
--
Gary's Student
gsnu200705


AidanS said:
Hi

Really appreciate the input. Apologise if follow-on queries a bit basic.

How do I check whether I have worksheet code module? Is there a way to
achieve the funcionality I need without that module?

I actually need to check a range of cells [A0 - An] and Insert the date in
Bx if the Ax has changed. How should I modify the code you provide to
achieve this?

Thanks again

A



Gary''s Student said:
Paste the following macro in worksheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A2"), Target) Is Nothing Then
Exit Sub
End If
Application.EnableEvents = False
Range("A1").Value = Now
Application.EnableEvents = True
End Sub

REMEMBER: worksheet code nat a standard module.
 
Works perfectly. Much appreciated.

Gary''s Student said:
No need for any apologies. First the update to the code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A:A"), Target) Is Nothing Then
Exit Sub
End If
Application.EnableEvents = False
Target.Offset(0, 1).Value = Now
Application.EnableEvents = True
End Sub


Because it is worksheet code, it is very easy to install and use:

1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window

Now try entering material in column A. If you have any concerns, first try
it onl a trial worksheet.

If you save the workbook, the macro will be saved with it.


To remove the macro:

1. bring up the VBE windows as above
2. clear the code out
3.close the VBE window
--
Gary's Student
gsnu200705


AidanS said:
Hi

Really appreciate the input. Apologise if follow-on queries a bit basic.

How do I check whether I have worksheet code module? Is there a way to
achieve the funcionality I need without that module?

I actually need to check a range of cells [A0 - An] and Insert the date in
Bx if the Ax has changed. How should I modify the code you provide to
achieve this?

Thanks again

A



Gary''s Student said:
Paste the following macro in worksheet code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A2"), Target) Is Nothing Then
Exit Sub
End If
Application.EnableEvents = False
Range("A1").Value = Now
Application.EnableEvents = True
End Sub

REMEMBER: worksheet code nat a standard module.
--
Gary's Student
gsnu200704


:

I want to automatically record in cell A1 the date that data in Cell A2 was
last changed. I want to simply register any change to data in Cell A2.
Seems a simple task but can't find the relevant function.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top