Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i am trying to use vba code to enter the date and time when a certain field
contains data.the code i have tried to use is: Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Target.Address = "$B$10":"$B$40" Then Range("A10:A40") = Time Range("G10:G40") = Date End If Application.EnableEvents = True End Sub please could you help thank you John Tempest |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
John,
What would you like to do? Let something happen after someone changed a cel in the range b10 : b40 ? grtx's, Martijn "john tempest" schreef in bericht ... i am trying to use vba code to enter the date and time when a certain field contains data.the code i have tried to use is: Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Target.Address = "$B$10":"$B$40" Then Range("A10:A40") = Time Range("G10:G40") = Date End If Application.EnableEvents = True End Sub please could you help thank you John Tempest |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
john tempest:
try it Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False Set bb = Union(Range("B10:B40"), Target) If Union(Target, Range("B10:B40")).Address = Range("B10:B40").Address Then Range("A10:A40") = Time Range("G10:G40") = Date End If Application.EnableEvents = True End Sub or Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False Set bb = Union(Range("B10:B40"), Target) If Union(Target, Range("B10:B40")).Address = Range("B10:B40").Address Then Cells(Target.Row, "A") = Time Cells(Target.Row, "G") = Date End If Application.EnableEvents = True End Sub -- 天行健,君*以自強不息 地勢坤,君*以厚德載物 http://www.vba.com.tw/plog/ "john tempest" wrote: i am trying to use vba code to enter the date and time when a certain field contains data.the code i have tried to use is: Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Target.Address = "$B$10":"$B$40" Then Range("A10:A40") = Time Range("G10:G40") = Date End If Application.EnableEvents = True End Sub please could you help thank you John Tempest |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
chijanzen
thankyou, your second piece of code is just what i was looking for regards john tempest "chijanzen" wrote: john tempest: try it Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False Set bb = Union(Range("B10:B40"), Target) If Union(Target, Range("B10:B40")).Address = Range("B10:B40").Address Then Range("A10:A40") = Time Range("G10:G40") = Date End If Application.EnableEvents = True End Sub or Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False Set bb = Union(Range("B10:B40"), Target) If Union(Target, Range("B10:B40")).Address = Range("B10:B40").Address Then Cells(Target.Row, "A") = Time Cells(Target.Row, "G") = Date End If Application.EnableEvents = True End Sub -- 天行健,君*以自強不息 地勢坤,君*以厚德載物 http://www.vba.com.tw/plog/ "john tempest" wrote: i am trying to use vba code to enter the date and time when a certain field contains data.the code i have tried to use is: Private Sub Worksheet_Change(ByVal Target As Range) Application.EnableEvents = False If Target.Address = "$B$10":"$B$40" Then Range("A10:A40") = Time Range("G10:G40") = Date End If Application.EnableEvents = True End Sub please could you help thank you John Tempest |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
can excel automatically enter the date data in a cell was entered | Excel Worksheet Functions | |||
projecting time and date from hours entered | Excel Worksheet Functions | |||
excel, automatic date and time when info gets entered | Excel Worksheet Functions | |||
Auto date/time insert when data entered into an adjacent cell | Excel Worksheet Functions | |||
Input Date when data is entered into another cell | Excel Worksheet Functions |