+ Reply to Thread
Results 1 to 6 of 6

Amendment to VBA code (Excel file open log history)

  1. #1
    Registered User
    Join Date
    08-26-2022
    Location
    West Midlands, United Kingdom
    MS-Off Ver
    Office 365
    Posts
    33

    Question Amendment to VBA code (Excel file open log history)

    Good afternoon all,

    I have a VBA code that i've taken from the web, that created a time stamp each time the excel file is opened, it takes the username, the date & time the file was opened, the problem is that this is all contained within a single cell,
    Is it possible some one could amend the code so that:
    • Username is contained within Column A
    • Date is contained within Column B
    • Time is contained within Column C.



    Please Login or Register  to view this content.
    Thank you very much for any replies.

    NOTE: I have not attached an example workbook to this post as I do not think it would be necessary.
    Last edited by Dazzur91; 11-09-2023 at 04:21 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,621

    Re: Amendment to VBA code (Excel file open log history)

    Yes, you probably don't need a workbook. But then I’m on an iPad so I can't test a solution anyway.

    So, good luck, and try this:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-26-2022
    Location
    West Midlands, United Kingdom
    MS-Off Ver
    Office 365
    Posts
    33

    Re: Amendment to VBA code (Excel file open log history)

    Morning TMS, thank you for your response & apologies for the delayed reply.

    I'm getting a debug error on the following line when implementing the code.

    Private Sub Workbook_Open()
    'Run from ThisWorkbook module.
    Dim UserName As String
    Dim lNR As Long
    UserName = Environ("UserName")

    With Worksheets("Open History")
    .lNR = .Range("A" & .Rows.Count).End(xlUp).Offset(1, 0).Row
    .Range("A" & lNR).Value = UserName
    .Range("B" & lNR).Value = Date
    .Range("C" & lNR).Value = Time
    End With

    ActiveWorkbook.Save

    End Sub
    Last edited by Dazzur91; 11-09-2023 at 04:13 AM.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,621

    Re: Amendment to VBA code (Excel file open log history)

    Sorry, remove the stop from in front of. lNR. It should be just lNR

  5. #5
    Registered User
    Join Date
    08-26-2022
    Location
    West Midlands, United Kingdom
    MS-Off Ver
    Office 365
    Posts
    33

    Re: Amendment to VBA code (Excel file open log history)

    Thanks for the swift response.

    Worked a treat, thank your help help & time.

    Have a great day (it's cold though, stay warm!) +Rep

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,621

    Re: Amendment to VBA code (Excel file open log history)

    Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Open an excel file, it without running code in it, copy its contents into another file
    By Kelly mort in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 07-30-2021, 01:41 AM
  2. Replies: 0
    Last Post: 10-02-2013, 01:47 AM
  3. [SOLVED] Code to open another excel file, file name depending on cell contents
    By L-Drr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2013, 11:09 AM
  4. VBA Code to Open An Excel File
    By Cfallscat in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-27-2011, 02:08 AM
  5. VBA for excel 2003. Open file dialog box, open 2007 file xlsx, continue with code
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2011, 12:12 AM
  6. Code to Open Excel File Please Help
    By Cole in forum Excel General
    Replies: 2
    Last Post: 07-10-2006, 04:09 PM
  7. Replies: 0
    Last Post: 03-29-2005, 11:06 AM

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