Autorun macro

J

Josh

OK, this is my attempt at making a static date so bear with me, i have 3
columns A- time. B- Data. C- Acutal Time. In the 'Actual Time' column it has
one cell being used with =NOW() in time format, and in the 'Time Column' it
has =IF(B2>0,C2). so that when i enter a value in the 'Data Column' it
transfers the current time into the 'Time Column' in the corresponding cell,
from here i have a macro which cuts and pastes the contents of the cell in
the 'Time' Column, it looks like this-------

Sub Macro2()
'
' Macro2 Macro
' copy paste
'

'
ActiveCell.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub

Ok so finally to the question, I want this macro to Autorun anytime the
value in the Data column changes, so it would work entering the time into the
'Time Column' cell next to it, Is this possible, if it is would someone be
able to tell me what to type when i make the macro, sorry i know im a bit
ammature
 
D

Don Guillett

As always, post your layout and code for comments. However, this macro may
do as desired without any formulas needed. It will put the time in col A
when you enter a number >0 in col B.
Right click the sheet tab>view code>insert this

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count <> 1 Then Exit Sub
If Target.Column <> 2 Then Exit Sub
If IsNumeric(Target) And Target > 0 Then
Target.Offset(, -1) = Time
End If
End Sub
 
D

Don Guillett

IF?? you want the DATE and time then change to
Target.Offset(, -1) = now
for date only
Target.Offset(, -1) = date
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top