+ Reply to Thread
Results 1 to 2 of 2

Entry in one cell stops a formula in another

  1. #1
    Registered User
    Join Date
    05-21-2009
    Location
    Chula Vista, CA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Entry in one cell stops a formula in another

    I have the following "timestamp" that says if there's an entry in a D cell, the adjacent E cell will get a timestamp.

    Here's the code:

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    With Target
    If .Count > 1 Then Exit Sub
    If Not Intersect(Range("D2:D5001"), .Cells) Is Nothing Then
    Application.EnableEvents = False
    If IsEmpty(.Value) Then
    .Offset(0, 1).ClearContents
    Else
    With .Offset(0, 1)
    .NumberFormat = "ddd mmm dd, yy hh:mm"
    .Value = Now
    End With
    End If
    Application.EnableEvents = True
    End If
    End With
    End Sub

    Now... in the F cell, I have the following formula that counts how many days have past since the timestamp.

    Here's the formula: =" Day " & DATEDIF(E2,TODAY(),"d")

    Dilemna #1:
    If entry in cell D triggers a timestamp in E... where F then starts to count how many days has passed since the timestamp in E... what code/formula/magic can I use when I enter something in G to stop cell F from counting anymore days.

    Here's a different way to look at it. I place sardines in a frying pan (D) which timestamps when I did it (E). (F) starts to count how many days have passed since I left the sardines in the pan. My house starts to stink... and I decide to stop the experiment (G) by entering STOP in the G cell.

    Phew! I hope this helps... and the sardines are making me hungry.

    Dilemna #2:
    How do I stop users from erasing the formula in cell F:
    =" Day " & DATEDIF(E2,TODAY(),"d")

    Thanks again.
    Last edited by Terrafai; 05-22-2009 at 07:42 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Entry in one cell stops a formula in another

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1