Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default date and time entered when a cell contains data

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default date and time entered when a cell contains data

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default date and time entered when a cell contains data

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default date and time entered when a cell contains data

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
can excel automatically enter the date data in a cell was entered mg_sv_r Excel Worksheet Functions 4 September 5th 08 11:09 AM
projecting time and date from hours entered Geoffery Excel Worksheet Functions 2 September 2nd 08 09:36 PM
excel, automatic date and time when info gets entered shorty Excel Worksheet Functions 4 April 26th 06 06:46 PM
Auto date/time insert when data entered into an adjacent cell Auto date/time Excel Worksheet Functions 1 July 9th 05 12:10 AM
Input Date when data is entered into another cell GaryByrd Excel Worksheet Functions 2 February 1st 05 12:37 AM


All times are GMT +1. The time now is 06:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"