Consulting

Results 1 to 15 of 15

Thread: Update Date

  1. #1
    VBAX Regular
    Joined
    Feb 2006
    Posts
    31
    Location

    Update Date

    Hi Team,
    Ever since I came here you guys have been nothing but helpful and I am very grateful for all your help and greatful of having such a great people in this forum.

    Here I have comeup with another request .
    Here I am attaching the spreadsheet.
    Could you please help me to update the date field ("Last Update" field in Nodes worksheet).

    When ever we modify/change any records in this worksheet, automatically the current date should be updated in "last update" field. Any ideas


    Thanks in advance,
    Suresh.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Suresh,
    Paste the following in the Nodes worksheet module
    Regards
    MD

    [vba]
    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    Cells(Target.Row, "P") = Int(Now())
    Application.EnableEvents = True
    End Sub

    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Feb 2006
    Posts
    31
    Location

    Update Date

    Hi MD,
    It is just working great. You guys are wonderful. Thanks somuch for your help.

    Suresh.

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Another KB entry Malcolm?!
    Perfect for the short line entries if we had one.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Good idea Steve.
    I think though, as it's a worksheet event, it would need some instruction for the Newbie, so maybe not a short line one in this case.
    Regards
    Malcolm
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I'm already using it and I'm sure others would find it useful. Thanks
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Any way to get this to ignore row 1 or the header row?

    [VBA]
    Cells(Target.Row, "P") = Int(Now())
    [/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  9. #9
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Row = 1 Then Exit Sub
    Application.EnableEvents = False
    Cells(Target.Row, "B") = Int(Now())
    Application.EnableEvents = True
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  10. #10
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Thanks Malcolm that works great
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  11. #11
    VBAX Regular
    Joined
    Feb 2006
    Posts
    31
    Location

    Update Date

    Hi MD, Steve and other team,
    Thanks for getting this done. Now it is perfectly working for me.
    Is there a way to send email (Through Lotus notes) to late clients (Compare the date field and if the date is >180 days, send email to them)??
    I have found few kb entries in our forum. Need to try them. If you have any ideas please share with me .

    Thanks,
    Suresh.

  12. #12
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Suresh,
    You should post this as a new question for a wider response.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  13. #13
    Quote Originally Posted by mdmackillop
    Cells(Target.Row, "P") = Int(Now())
    Malcolm, is there a reason you chose Int(Now()) instead of =Date??

  14. #14
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Sid
    No good reason. Whatever works, but I agree Date is better!
    Regards
    Malcolm
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  15. #15
    VBAX Contributor
    Joined
    Jul 2005
    Posts
    169
    Location
    Hi,
    the following code doesn't update if the change made is the same as before the change
    and also no update for just delete key on the empty cell....
    [vba]
    Private OldData As Variant

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    OldData = Target.Value
    End Sub

    Private Sub Worksheet_Change(ByVal Target As Range)
    With Target
    If .Row = 1 Then Exit Sub
    If .Value = OldData Then Exit Sub
    Application.EnableEvents = False
    Range("p" & .Row) = Date
    Application.EnableEvents = True
    End With
    End Sub
    [/vba]

Posting Permissions

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