VBA code to update Excel date only if changes occur

katkth7533

New Member
Joined
Aug 18, 2014
Messages
14
Hi! I was hoping someone can help me with a vba code for Excel. I have a worksheet where I want the status date to update automatically to the current date but only when data is changed within certain cells; not when the file is opened or saved. In my example, the worksheet is called "Milestone". I want the date in cell "L2" to reflect the current date if ANY thing is changed in cells "B7:L35". And only on this sheet. I keep getting stuck. Any ideas? Thank you!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Place this macro in the code module for your "Milestone" worksheet:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim WorkRange As Range
    Dim DateRange As Range
    
    With Me
        Set WorkRange = .Range("B7:L35")
        Set DateRange = .Range("L2")
    End With
    
    If Not Intersect(Target, WorkRange) Is Nothing Then
        DateRange.Value = Date
    End If

End Sub
 
Upvote 0
Hello can you help me with the code to use. I want my sheet not to auto update the date when no changes made. But it appears that the date always updated to the current date. Please me.
 
Upvote 0
Every time I press the process button to sheet 2 and there is a msg appear the this plan already process want to continue. I selected NO. but the date in sheet 1 change into current date
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

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