+ Reply to Thread
Results 1 to 3 of 3

Double Click Macro VBA - entering 'signature' user id in cells

Hybrid View

  1. #1
    Registered User
    Join Date
    11-25-2014
    Location
    Lincoln, UK
    MS-Off Ver
    2010
    Posts
    19

    Question Double Click Macro VBA - entering 'signature' user id in cells

    Hi,

    I have used this coding before but for a maximum of two column ranges. In this case I have 5 columns which we want to be able to be 'signed' by double-clicking and auto entering the user ID time stamp. Can anyone help fix this coding to allow for this?

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        Dim myrange As Range
        Dim myCalc As XlCalculationState
        Dim ws As Worksheet
        Dim r As Long
        
        Application.ScreenUpdating = False
     
        Set myrange = ActiveSheet.Range("Signature")
    
        If Target.Cells.Count > 1 Then
            Exit Sub
        End If
        
        If Intersect(Target, myrange) Is Nothing Then
            Exit Sub
        End If
     
            If ActiveCell > 0 Then
            MsgBox "Already Actioned", vbInformation, "Error"
            Cancel = True
            Exit Sub
        End If
     
        If MsgBox("Confirm Submission / Authorisation?", vbYesNo + vbQuestion, "Submit / Authorise") = vbNo Then
            Cancel = True
            Exit Sub
        End If
    
        myCalc = Application.Calculation
        Application.Calculation = xlCalculationManual
        
        r = Target.Row
     
        If ActiveSheet.Cells(Target.Row, 17) <= 0 Then
               ActiveSheet.Cells(r, 17).Value = Environ("Username") & " " & Format(Now, "hh:mm dd-mmm-yy")
        ElseIf ActiveSheet.Cells(Target.Row, 17) > 0 Then
                   ActiveSheet.Cells(r, 18).Value = Environ("Username") & " " & Format(Now, "hh:mm dd-mmm-yy")
         
        End If
     
        Cancel = True
     
        Application.Calculation = myCalc
        Application.ScreenUpdating = True
    End Sub

    Thank you!
    Attached Images Attached Images
    Last edited by ashtally; 01-29-2015 at 12:25 PM.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Double Click Macro VBA - entering 'signature' user id in cells

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Double Click Macro VBA - entering 'signature' user id in cells

    Still not quite clear what you actually want to achieve. A screenshot is pretty useless (I'm not going to try to recreate your workbook structure from an image) - an example workbook showing what you are trying to achieve would be more useful.

    If it's as simple as: when a user double-clicks a cell in columns Q:U, the username and current time are entered in that cell, then you can simply use:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        If Target.Cells.Count > 1 Then Exit Sub
        If Not Intersect(Target, Range("Q:U")) Is Nothing Then
            If Target.Value > 0 Then
                MsgBox "Already Actioned", vbInformation + vbOKOnly, "Error"
            ElseIf MsgBox("Confirm Submission / Authorisation?", vbYesNo + vbQuestion, "Submit / Authorise") = vbYes Then
                Target.Value = Environ("UserName") & Format(Now, "hh:mm dd-mm-yy")
            End If
            Cancel = True
        End If
    End Sub

+ 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. Changing cell properties with double click, then revert with another double click
    By mweber2525 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-01-2014, 01:40 PM
  2. how to run my macro with double click
    By snapajap in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-05-2013, 02:42 PM
  3. Double click a certain cell to insert a signature image
    By SpringLily in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-27-2011, 11:43 AM
  4. Is there a macro that can double click on a range of cells?
    By xiaodi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2011, 11:12 PM
  5. Run macro on double click only
    By famdamly in forum Excel General
    Replies: 2
    Last Post: 02-27-2006, 08:20 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