+ Reply to Thread
Results 1 to 6 of 6

Double click to fill cell with date&time and a cell before with applicationuser name

  1. #1
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Smile Double click to fill cell with date&time and a cell before with applicationuser name

    Hi all,
    I am struggling with the following code.
    Double click function to populate date and time ( NOW) has been achieved and is working fine.

    I want to add to this code to populate application.username in the adjacent cell before with application.username.

    If this is achieved, then I further want to shrink the name to ( first name and then initials- as derived from applicationusername)

    Is this possible
    Any help please.
    Please see attached file
    Code:
    Please Login or Register  to view this content.
    Kind regards
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Double click to fill cell with date&time and a cell before with applicationuser name

    Sorry , the file was not attached correctly.

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Sheets("sheet1").Unprotect "abcd"
    Application.ScreenUpdating = False
    If Not Intersect(Target, Range("B:B")) Is Nothing Then
    Target.Value = Now()
    'I want to add code here that in column A corresponding cell ( range A:A )will have application.username.
    'in the application username Only the first name and last name as initials ( e.g.) if name is Mike Pat then it will be Mike P
    Cancel = True
    Sheets("sheet1").Protect "abcd"
    Application.ScreenUpdating = True
    End If
    End Sub
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Double click to fill cell with date&time and a cell before with applicationuser name

    Hi everyone,
    I have resolved the first part.
    New code is as follows.
    Please Login or Register  to view this content.
    Any help will be appriciated

  4. #4
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Double click to fill cell with date&time and a cell before with applicationuser name

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Sheets("sheet1").Unprotect "abcd"
    Application.ScreenUpdating = False
    If Not Intersect(Target, Range("B:B")) Is Nothing Then
    'added following line and works fine
    Target.Offset(0, -1) = Application.UserName
    'I want to shrink name to first name and initial now
    Target.Value = Now()
    Cancel = True
    Sheets("sheet1").Protect "abcd"
    Application.ScreenUpdating = True
    End If
    End Sub

  5. #5
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Double click to fill cell with date&time and a cell before with applicationuser name

    Apology
    Clicked twice and made a mistake. Code tags are missing
    Apology

  6. #6
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Double click to fill cell with date&time and a cell before with applicationuser name

    Hi all,
    Thanks
    I have found solution using formula instead of vba to separate first name from full name & second name as initials.
    Many thanks everyone.
    I am closing this thread
    Kind regards

+ 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. Double click cell to insert current Time
    By Vetequk in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-17-2013, 10:30 AM
  2. Auto fill Date + Double click (time stamp)
    By SVTF in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-05-2012, 03:29 PM
  3. double click a cell with Date format
    By qqxz in forum Excel General
    Replies: 1
    Last Post: 01-24-2006, 10:50 AM
  4. Replies: 2
    Last Post: 08-06-2005, 04:05 PM
  5. How do I code a cell to display the current date on double-click?
    By George in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-14-2005, 01: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