Computing.Net > Forums > Office Software > how to automatically freeze formula

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

how to automatically freeze formula

Reply to Message Icon

Name: JerryH
Date: December 1, 2004 at 09:28:23 Pacific
OS: XP Pro
CPU/Ram: AMDXP 1700 / PC2100 256 D
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Grok Lobster
Date: December 1, 2004 at 15:29:29 Pacific
Reply:

I have only ever seen it done via an AutoClose macro


0

Response Number 2
Name: A Certain TH
Date: December 2, 2004 at 06:58:28 Pacific
Reply:

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 Boolean

Private 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 Sub

BUT: 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


0

Response Number 3
Name: JerryH
Date: December 2, 2004 at 11:51:15 Pacific
Reply:

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



0

Response Number 4
Name: A Certain TH
Date: December 2, 2004 at 14:09:34 Pacific
Reply:

If there is any other code there, then copy and paste it back up here and I'll let you know!

Tom


0

Response Number 5
Name: JerryH
Date: December 3, 2004 at 02:17:01 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: A Certain TH
Date: December 3, 2004 at 08:13:38 Pacific
Reply:

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 Boolean

Private 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 Sub

and that should work.

Cheers
Tom


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: how to automatically freeze formula

How to writ a formula in Excel www.computing.net/answers/office/how-to-writ-a-formula-in-excel/311.html

How to use cell ref as a variable www.computing.net/answers/office/how-to-use-cell-ref-as-a-variable/6011.html

how to resolve a formula? www.computing.net/answers/office/how-to-resolve-a-formula/9453.html