+ Reply to Thread
Results 1 to 10 of 10

Multiple events for double click action

Hybrid View

ilker11 Multiple events for double... 05-02-2020, 11:03 AM
zzzeddy Re: Multiple events for... 05-02-2020, 12:12 PM
ilker11 Re: Multiple events for... 05-02-2020, 12:45 PM
Greg M Re: Multiple events for... 05-02-2020, 12:21 PM
ilker11 Re: Multiple events for... 05-02-2020, 12:52 PM
ilker11 Re: Multiple events for... 05-02-2020, 12:53 PM
Greg M Re: Multiple events for... 05-02-2020, 03:40 PM
ilker11 Re: Multiple events for... 05-02-2020, 03:43 PM
Greg M Re: Multiple events for... 05-03-2020, 07:10 AM
ilker11 Re: Multiple events for... 05-03-2020, 08:33 AM
  1. #1
    Registered User
    Join Date
    05-02-2020
    Location
    cyprus
    MS-Off Ver
    office2007
    Posts
    6

    Multiple events for double click action

    Hello everyone,

    First post here.

    I have a workbook consisting of two sheets, I want to be able to double click on a cell in column C to copy the data of that cell and also the data in column H and paste them in next empty row in sheet 2.

    I managed to do just one with the following code but can't get it to work with both functions.

    Any help is much appreciated.

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Not Intersect(Target, Range("C2:C10")) Is Nothing Then
    Cancel = True
    Target.Copy
    Sheets("INV").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlPasteValues
    Application.CutCopyMode = False
    End If

    Sheets("INV").Select

    End Sub


    I want it to also copy "H2:H10" to next empty row (B) in "INV"

  2. #2
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    492

    Re: Multiple events for double click action

    Hi

    Welcome to the Forum.

    Try this
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
    If Not Intersect(Target, Range("C2:C10")) Is Nothing Then
    Cancel = True
    r = Target.Row
    zValue1 = Target.Value
    zValue2 = Cells(r, "H")
    
    k = Sheets("INV").Range("A" & Rows.Count).End(xlUp).Row
    Sheets("INV").Cells(k + 1, "A") = zValue1
    Sheets("INV").Cells(k + 1, "B") = zValue2
    End If
    
    Sheets("INV").Select
    
    End Sub
    zeddy
    P.S. better wrap your posted code with tags before you get caught and admonished

  3. #3
    Registered User
    Join Date
    05-02-2020
    Location
    cyprus
    MS-Off Ver
    office2007
    Posts
    6

    Re: Multiple events for double click action

    Quote Originally Posted by zzzeddy View Post
    zeddy
    P.S. better wrap your posted code with tags before you get caught and admonished
    I don't quite follow what you mean by this.

    Thanks for the answer, it works perfect. Is it also possible to deduce the stock level by "1" which is in column "I"?

    Many thanks for your help.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: Multiple events for double click action

    Hi there,

    See if the following code does what you need:

    
    
    
    Option Explicit
    
    
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
        Const sOTHER_COLUMN As String = "H"
    
        Dim vDataValue_1    As Variant
        Dim vDataValue_2    As Variant
    
        If Not Intersect(Target, Range("C2:C10")) Is Nothing Then
    
            vDataValue_1 = Target.Value
    
            vDataValue_2 = Intersect(Target.EntireRow, _
                                     Me.Columns(sOTHER_COLUMN)).Value
    
            With Sheets("INV").Range("A" & Rows.Count).End(xlUp).Offset(1)
    
                .Cells(1, 1).Value = vDataValue_1
                .Cells(1, 2).Value = vDataValue_2
    
                .Parent.Select
    
            End With
    
            Cancel = True
    
        End If
    
    End Sub
    The highlighted value may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M

  5. #5
    Registered User
    Join Date
    05-02-2020
    Location
    cyprus
    MS-Off Ver
    office2007
    Posts
    6

    Re: Multiple events for double click action

    This also works as intended.

    Many thanks

  6. #6
    Registered User
    Join Date
    05-02-2020
    Location
    cyprus
    MS-Off Ver
    office2007
    Posts
    6

    Re: Multiple events for double click action

    Quote Originally Posted by Greg M View Post
    Hi there,

    See if the following code does what you need:

    
    
    
    Option Explicit
    
    
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
        Const sOTHER_COLUMN As String = "H"
    
        Dim vDataValue_1    As Variant
        Dim vDataValue_2    As Variant
    
        If Not Intersect(Target, Range("C2:C10")) Is Nothing Then
    
            vDataValue_1 = Target.Value
    
            vDataValue_2 = Intersect(Target.EntireRow, _
                                     Me.Columns(sOTHER_COLUMN)).Value
    
            With Sheets("INV").Range("A" & Rows.Count).End(xlUp).Offset(1)
    
                .Cells(1, 1).Value = vDataValue_1
                .Cells(1, 2).Value = vDataValue_2
    
                .Parent.Select
    
            End With
    
            Cancel = True
    
        End If
    
    End Sub
    The highlighted value may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    This also works as intended.

    Many thanks

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: Multiple events for double click action

    Hi again,

    Many thanks for your very prompt feedback.

    You're welcome - glad I was able to help.

    Regards,

    Greg M

  8. #8
    Registered User
    Join Date
    05-02-2020
    Location
    cyprus
    MS-Off Ver
    office2007
    Posts
    6

    Re: Multiple events for double click action

    Quote Originally Posted by Greg M View Post
    Hi again,

    Many thanks for your very prompt feedback.

    You're welcome - glad I was able to help.

    Regards,

    Greg M
    Dear Greg,

    Is it possible to add another function?
    I'd like to deduct stock quantity by 1 in column "I"

    many thanks

  9. #9
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: Multiple events for double click action

    Hi there,

    I think the following code should do what you need:

    
    
    Option Explicit
    
    
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
        Const sSTOCK_COLUMN As String = "I"
        Const sOTHER_COLUMN As String = "H"
    
        Dim vDataValue_1    As Variant
        Dim vDataValue_2    As Variant
        Dim rStockCell      As Range
    
        If Not Intersect(Target, Range("C2:C10")) Is Nothing Then
    
            vDataValue_1 = Target.Value
    
            vDataValue_2 = Intersect(Target.EntireRow, _
                                     Me.Columns(sOTHER_COLUMN)).Value
    
            Set rStockCell = Intersect(Target.EntireRow, _
                                       Me.Columns(sSTOCK_COLUMN))
    
            rStockCell.Value = rStockCell.Value - 1
    
            With Sheets("INV").Range("A" & Rows.Count).End(xlUp).Offset(1)
    
                .Cells(1, 1).Value = vDataValue_1
                .Cells(1, 2).Value = vDataValue_2
    
                .Parent.Select
    
            End With
    
            Cancel = True
    
        End If
    
    End Sub
    The highlighted values may be altered to suit your requirements.


    Hope this helps - as before, please let me know how you get on.

    Regards,

    Greg M

  10. #10
    Registered User
    Join Date
    05-02-2020
    Location
    cyprus
    MS-Off Ver
    office2007
    Posts
    6

    Re: Multiple events for double click action

    Quote Originally Posted by Greg M View Post
    Hi there,

    I think the following code should do what you need:

    
    
    Option Explicit
    
    
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
        Const sSTOCK_COLUMN As String = "I"
        Const sOTHER_COLUMN As String = "H"
    
        Dim vDataValue_1    As Variant
        Dim vDataValue_2    As Variant
        Dim rStockCell      As Range
    
        If Not Intersect(Target, Range("C2:C10")) Is Nothing Then
    
            vDataValue_1 = Target.Value
    
            vDataValue_2 = Intersect(Target.EntireRow, _
                                     Me.Columns(sOTHER_COLUMN)).Value
    
            Set rStockCell = Intersect(Target.EntireRow, _
                                       Me.Columns(sSTOCK_COLUMN))
    
            rStockCell.Value = rStockCell.Value - 1
    
            With Sheets("INV").Range("A" & Rows.Count).End(xlUp).Offset(1)
    
                .Cells(1, 1).Value = vDataValue_1
                .Cells(1, 2).Value = vDataValue_2
    
                .Parent.Select
    
            End With
    
            Cancel = True
    
        End If
    
    End Sub
    The highlighted values may be altered to suit your requirements.


    Hope this helps - as before, please let me know how you get on.

    Regards,

    Greg M
    This works perfect, thank you.

    One last question if you don't mind.

    Instead of integrating this code to change quantity with the double click action, is it possible to link qty column on the invoice to the inventory sheet?

    For example, I double click on the product which transfers it to the invoice and then when update the qty on the invoice it automatically updates the qty on the stock list for that specific product.

    Many thanks

+ 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] Double Click one sheet and replicate Double Click "mark" on other sheets
    By jeffreybrown in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-14-2018, 08:43 AM
  2. [SOLVED] Add 1 to target on double click, add 0.5 on shift + double click
    By MarmaladeLover in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-26-2015, 06:59 AM
  3. Macro to perform Double Click Action
    By got_flat_1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-21-2014, 04:29 PM
  4. VBA double-click item from listview not firing events
    By kriz6912 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2014, 07:39 AM
  5. 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
  6. Using double-click on mouse to perform an action?
    By mgarcia in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-19-2009, 12:52 AM
  7. Two double click events?
    By PG Oriel in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-07-2006, 03:55 PM

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