Excel macro double-click

Posted on 2011-10-05
Last Modified: 2012-05-12
Hi, I want to create a macro that pops up a message when I double-click a cell. Is this possible?
Can anyone help?
Question by:HKFuey
    LVL 17

    Accepted Solution

    Try this code in whichever sheet you want the box to appear:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
     MsgBox ("test message")
    End Sub

    Open in new window


    Author Closing Comment

    Superb, just what I needed, thanks!
    LVL 17

    Expert Comment

    Thanks. As a follow up, if you needed the message box to show for double clicking on only one cell rather than any cell in the sheet, this code would be sufficient:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
     Dim LookIn As Range
        Set LookIn = Me.Range("A1")
        If Intersect(Target, LookIn) Is Nothing Then Exit Sub
        If ActiveCell = LookIn Then
        MsgBox ("Test message")
        End If
    End Sub

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now