+ Reply to Thread
Results 1 to 6 of 6

Date/User stamp for named range

  1. #1
    Registered User
    Join Date
    07-22-2009
    Location
    Gillingham, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Date/User stamp for named range

    Hi,

    I'm currently using the following code to stamp a date and username for any rows changed.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim x As Range
    Set myRange = ActiveCell

    If Target.Column <= 13 and Target.row >= 2 Then

    Cells(Target.Row, "N").Select
    ActiveCell.Offset(0, 0) = Date
    ActiveCell.Offset(0, 1) = Environ("USERNAME")

    myRange.Select

    End If
    End Sub

    How can i change this so it applies to a named workbook range (in this case 'outstanding_entries') rather than anything which is <= 13 columns and >= 2 row?

    Any help would be grateful!

    Regards

    James

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Date/User stamp for named range

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-22-2009
    Location
    Gillingham, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Date/User stamp for named range

    Hi thanks for your help.

    The code seems to be setting the named range correctly. However, when I change something in a row in the specified range, the system hangs trying to stamp the username.

    the code i'm using is:

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("outstanding_entries")) Is Nothing Then

    Cells(Target.Row, "N").Select
    ActiveCell.Offset(0, 0) = Date
    ActiveCell.Offset(0, 1) = Environ("USERNAME")

    End If

    End Sub


    Any ideas why this is?

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Date/User stamp for named range

    works for me.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    07-22-2009
    Location
    Gillingham, England
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Date/User stamp for named range

    I worked it out.

    The named range i was referencing was a dynamic range, which encapsulated the columns the VBA code would write to, therefore it would continually write to the spreadsheet and was stuck in a loop.

    Thanks for all your help!

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Date/User stamp for named range

    roden_uk,

    I am glad you have a resolution however I would ask you edit your posts and add CODE tags around your VBA so as to adhere to the Forum Rules.

+ 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