Stop counting days

kweisser

New Member
Joined
Jul 7, 2008
Messages
17
I have a formula to count number of days that I would then like to stop once another cell is populated with a date. I have the following formula that works for the counting, but not sure how to add the additional steps to stop once the neighboring cell (J2) is populated. Any help is most appreciated.

IF(AND(H2="",I2=""),"",IF(H2>I2,(H2+7)-TODAY(),(I2+7)-TODAY()))<o:p></o:p>
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
You may want to look at a Worksheet_Change Event. For example when cell J2 is populated it will put a time stamp in the adjacent cell.

Try putting this code in the worksheet module of the worksheet your data is on:
Code:
[COLOR=#0000ff]Private Sub [/COLOR]Worksheet_Change([COLOR=#0000ff]ByVal [/COLOR]Target[COLOR=#0000ff] As [/COLOR]Excel.Range)
    [COLOR=#0000ff]If [/COLOR]Range("J2") <> "" [COLOR=#0000ff]Then[/COLOR]
         Range("I2") = Format(Now(), "m.d.yy h:mm AM/PM")
[COLOR=#0000ff]    End If[/COLOR]
[COLOR=#0000ff]
[/COLOR]
[COLOR=#0000ff]End Sub[/COLOR]

It will timestamp cell i2 if cell j2 is not blank ("")
 
Upvote 0
This may work better. It will only change the timestamp value if cell j2 is modified. Otherwise the timestamp value may change every time a change is made to the worksheet:

Code:
[COLOR=#0000ff]Private Sub [/COLOR]Worksheet_Change([COLOR=#0000ff]ByVal[/COLOR] Target [COLOR=#0000ff]As [/COLOR]Excel.Range)
  [COLOR=#0000ff]  If [/COLOR]Target.Column = 10 [COLOR=#0000ff]And [/COLOR]Target.Row = 2 [COLOR=#0000ff]Then[/COLOR]
   [COLOR=#0000ff]    If [/COLOR]Range("J2") <> "" [COLOR=#0000ff]Then[/COLOR]
            Range("I2") = Format(Now(), "m.d.yy. h:mm AM/PM")
[COLOR=#0000ff]        End If[/COLOR]
[COLOR=#0000ff]    End If[/COLOR]
[COLOR=#0000ff]End Sub[/COLOR]
There may be a better way to go about this with a formula. Not too sure though...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,013
Messages
6,122,694
Members
449,092
Latest member
snoom82

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top