+ Reply to Thread
Results 1 to 4 of 4

date and time entered when a cell contains data

  1. #1
    john tempest
    Guest

    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. #2
    Martijn
    Guest

    Re: 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" <[email protected]> schreef in bericht
    news:[email protected]...
    > 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. #3
    chijanzen
    Guest

    RE: 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. #4
    john tempest
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1