ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Autorun macro (https://www.excelbanter.com/excel-discussion-misc-queries/239856-autorun-macro.html)

Josh

Autorun macro
 
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(B20,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


Don Guillett

Autorun macro
 
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 tabview codeinsert 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
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Josh" wrote in message
...
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(B20,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



Don Guillett

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


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
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 tabview codeinsert 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
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Josh" wrote in message
...
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(B20,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





All times are GMT +1. The time now is 01:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com