Vba - auto update date

vba_rook

New Member
Joined
Nov 8, 2012
Messages
2
Hi all,

This is my first time posting on here on this forum.

I am completely new to VBA and Macros but have done a bit of reading on forums across the web but am still struggling with figuring out all the VBA verbiage.

I am looking to write a code that will auto update the cell in column A with today's date whenever any cell in that row is entered or changed. The data table will have hundreds of rows of entries.

Much appreciation for the help in advance.

Thank you,
Sinny
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
try using:
=today()
in the cell. That should update automatically without the need of a macro
 
Upvote 0
Hi dermie,

Thanks for the quick response.

By using the =today() function, the dates will auto-update even if I am just opening the excel file which is not what I am looking to do.

I only want the date value to change if another value in that row is changed or if new data is entered.
 
Upvote 0
Hi vba_rook.

I did a "VBA DATE STAMP" search in help and found one written by Barb-B in 2010.

I did edit it a bit to suit your sheet and you may have to edit it some more to fit your range. (See 'my edit )

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim Fcells As Range
Dim CL As Range
Dim i As Integer ' my edit
i = Target.Column 'my edit

Application.ScreenUpdating = False
Application.EnableEvents = False

On Error Resume Next
'Set Fcells = Intersect(Target, Range("F:F"))
Set Fcells = Intersect(Target, Range("B1:K10")) 'my edit - adjust range to your hundreds of rows...
If Fcells <> Empty Then
For Each CL In Fcells.Cells
'CL.Offset(0, 2) = Date
CL.Offset(0, -(i - 1)) = Date 'my edit
Next CL
End If

Set Fcells = Nothing
Application.ScreenUpdating = True
Application.EnableEvents = True

End Sub

HTH
Regards,
Howard
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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