Populate Date Daily

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
922
Office Version
  1. 365
Hi,

I have the following data entry table:

Book1
BCD
6DateProfitLoss
79/9/202125
Sheet1
Cell Formulas
RangeFormula
B7B7=IF(COUNTA(C7:D7)>0,TODAY(),"")


I am trying to build a formula in column B which will automatically populate the date for the particular day in which any profit or loss has been entered in column C or D. Example : today is 9/9/2021, the date should populate as 9/9/21. When we cross over to tomorrow, this date should not change and should remain as 9/9/21. Is there a way to modify my current formula in cell B7? Appreciate all the help.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I don't think you can use a formula to do it, as TODAY() always returns the current date, so that value is constantly changing (and is not static).
However, you can use VBA to do it.

Right-click on the sheet tab name at the bottom of the screen, select "View Code", and paste this into the VB Editor window that pops up:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

'   Exit if more than one cell updated simultaneously
    If Target.CountLarge > 1 Then Exit Sub
    
'   Exit if no value is updated
    If Target.Value = "" Then Exit Sub
    
'   Only run if columns C or D updated and after row 6
    If (Target.Row > 6) And ((Target.Column = 3) Or (Target.Column = 4)) Then
'       Put current date in column B
        Cells(Target.Row, "B") = Date
    End If

End Sub
This should automatically add the current date (as a hard-coded value) in column B as you make entries to columns C and D.
 
Upvote 0
Solution
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

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