Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I could do with a few pointers if poss - usually not to bad on excel but stuck on this one.
I would like cell A2 to look at cell A1 and when there is an entry made in A1, for A2 to display the date that entry was placed.
I can do that using today(), but that will change each different day I open the workbook.
I would like the cell A2 to display the original date no matter how many times the workbook is opened. There is a way in the excel help file by clicking onto A2, copying and then using paste special then choosing values. However that is a manual process that takes longer than just typing the date itself.Can anyone please help?
I'm sure I've used something like this before, but damned if I can remember how !!!!!Fingers crossed,
JerryH

Right click the sheet tab
Select "View Code"
Paste in the following:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then Range("A2") = Date
End Sub
If you want a more general one that will put a date under any cell thats changed then go for:
Public inMacro As BooleanPrivate Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo GetOut
If inMacro Then inMacro = False: Exit Sub
inMacro = True
Range(Target.Address).Offset(1, 0) = Date
GetOut:
End
End SubBUT: Remember that if you use code to update a worksheet, then you lose your entire "Undo" history each time it updates.
Hope that helps
Tom

Tom,
thanks for that, will try that tomorrow and see what happens.
Do I add the first info ie"Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then Range("A2") = Date
End Sub"to any code that may already be shown when I right click and view code
or
use it to replace any code already there???You responce would be appreciated.
Thanks,
JerryH

Tom,
The following code was shown when I looked. Any ideas?"Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
End Sub"
also
I had simplified my original question, not expecting this type of answer. What I intend is that -
B1 and D1 look at A1, when there is an input in A1 then both B1 and D1 display the date when A1 info was input. That original date has to remain no matter how often the workbook is opened. Following on from that, B2 and D2 look at A2 for an input and then also display the date A2 had info input. This carries on down to B100, D100 and A100.Hope I've explained it ok and look forward to your comments.
Regards,
JerryH

1) That text automatically appears and is just the brackets around a coded procedure - just overwrite it, as it does nothing in itself.
2) OK - so you need my version 2, slightly adjusted:
Public inMacro As BooleanPrivate Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo GetOut
If inMacro Then inMacro = False: Exit Sub
inMacro = True
If Target.Column = 1 And Target.Row <= 100 Then
Range(Target.Address).Offset(0, 1) = Date
Range(Target.Address).Offset(0, 3) = Date
End If
GetOut:
End
End Suband that should work.
Cheers
Tom

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |