Re: Auto Date and Time?

kl2190

New Member
Joined
Oct 28, 2010
Messages
15
Re: Auto Date and Time?

Private Sub Worksheet_Change(ByVal Target As Range)
' Automatically adds date and time

If Target.Column = 5 Then
Target.Offset(0, 5).Value = Date
End If
End Sub

sorry to drag this one back up. The above works great. how can i modify the code so that it only fills in the date when certain text ("COMPLETED") is entered into the specified column? much appreciated.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Re: Auto Date and Time?

Do you understand what the macro is doing? Because this is only a minor change to the above:

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
' Automatically adds date and time

If Target.Column = 5 And Target.Value = "COMPLETED" Then
   Target.Offset(0, 5).Value = Date
End If
End Sub

You will want to add a line of code that checks whether 1 or more cells were changed. Because in the latter case, Target.Column and Target.Value will yield errors.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

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