how to run macro in double click on a particular cell

Discussion in 'Microsoft Excel Programming' started by Khizhavan, Aug 11, 2008.

  1. Khizhavan

    Khizhavan Guest

    How to run macro in double click on a particular cell?

    let me know, how we can run a macro when i am pressing double click on
    particular cell.

    Thanks
     
    Khizhavan, Aug 11, 2008
    #1
    1. Advertisements

  2. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
    Boolean)
    If Intersect(Target, Range("B9")) Is Nothing Then
    Else
    MsgBox ("Hello Khizhavan")
    End If
    End Sub


    Because it is worksheet code, it is very easy to install and automatic to use:

    1. right-click the tab name near the bottom of the Excel window
    2. select View Code - this brings up a VBE window
    3. paste the stuff in and close the VBE window

    If you have any concerns, first try it on a trial worksheet.

    If you save the workbook, the macro will be saved with it.


    To remove the macro:

    1. bring up the VBE windows as above
    2. clear the code out
    3. close the VBE window

    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    To learn more about Event Macros (worksheet code), see:

    http://www.mvps.org/dmcritchie/excel/event.htm

    --
    Gary''s Student - gsnu200799


    "Khizhavan" wrote:

    > How to run macro in double click on a particular cell?
    >
    > let me know, how we can run a macro when i am pressing double click on
    > particular cell.
    >
    > Thanks
    >
     
    Gary''s Student, Aug 11, 2008
    #2
    1. Advertisements

  3. Khizhavan

    RocketRod Guest

    Gary - can you help me further - this is exactly what I need but it is not
    working for me.
    I created a new sheet in my workbook and did the view code thing by right
    clicking on the sheet name

    I pasted the following in (I have just copied it out of it here to be ceratin)

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
    Boolean)
    If Intersect(Target, Range("B9")) Is Nothing Then
    Else
    MsgBox ("Hello Khizhavan")
    End If
    End Sub


    I assume that if I double click cell B9 on that sheet the Msgbox should
    display but it doesn't

    I must be missing something?



    "Gary''s Student" wrote:

    > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
    > Boolean)
    > If Intersect(Target, Range("B9")) Is Nothing Then
    > Else
    > MsgBox ("Hello Khizhavan")
    > End If
    > End Sub
    >
    >
    > Because it is worksheet code, it is very easy to install and automatic to use:
    >
    > 1. right-click the tab name near the bottom of the Excel window
    > 2. select View Code - this brings up a VBE window
    > 3. paste the stuff in and close the VBE window
    >
    > If you have any concerns, first try it on a trial worksheet.
    >
    > If you save the workbook, the macro will be saved with it.
    >
    >
    > To remove the macro:
    >
    > 1. bring up the VBE windows as above
    > 2. clear the code out
    > 3. close the VBE window
    >
    > To learn more about macros in general, see:
    >
    > http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >
    > To learn more about Event Macros (worksheet code), see:
    >
    > http://www.mvps.org/dmcritchie/excel/event.htm
    >
    > --
    > Gary''s Student - gsnu200799
    >
    >
    > "Khizhavan" wrote:
    >
    > > How to run macro in double click on a particular cell?
    > >
    > > let me know, how we can run a macro when i am pressing double click on
    > > particular cell.
    > >
    > > Thanks
    > >
     
    RocketRod, Oct 6, 2008
    #3
  4. Khizhavan

    RocketRod Guest

    ignore that.
    I tried again and it worked - go figure!

    "Gary''s Student" wrote:

    > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
    > Boolean)
    > If Intersect(Target, Range("B9")) Is Nothing Then
    > Else
    > MsgBox ("Hello Khizhavan")
    > End If
    > End Sub
    >
    >
    > Because it is worksheet code, it is very easy to install and automatic to use:
    >
    > 1. right-click the tab name near the bottom of the Excel window
    > 2. select View Code - this brings up a VBE window
    > 3. paste the stuff in and close the VBE window
    >
    > If you have any concerns, first try it on a trial worksheet.
    >
    > If you save the workbook, the macro will be saved with it.
    >
    >
    > To remove the macro:
    >
    > 1. bring up the VBE windows as above
    > 2. clear the code out
    > 3. close the VBE window
    >
    > To learn more about macros in general, see:
    >
    > http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >
    > To learn more about Event Macros (worksheet code), see:
    >
    > http://www.mvps.org/dmcritchie/excel/event.htm
    >
    > --
    > Gary''s Student - gsnu200799
    >
    >
    > "Khizhavan" wrote:
    >
    > > How to run macro in double click on a particular cell?
    > >
    > > let me know, how we can run a macro when i am pressing double click on
    > > particular cell.
    > >
    > > Thanks
    > >
     
    RocketRod, Oct 6, 2008
    #4
  5. Khizhavan

    Don Guillett Guest

    could have been a one liner

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
    Boolean)
    If Not Intersect(Target, Range("B9")) Is Nothing Then MsgBox "Hello"

    'or using absolutes and UPPER case
    'if target.address="$B$9" then msgbox "hello"
    End Sub


    --
    Don Guillett
    Microsoft MVP Excel
    SalesAid Software

    "RocketRod" <> wrote in message
    news:D...
    > ignore that.
    > I tried again and it worked - go figure!
    >
    > "Gary''s Student" wrote:
    >
    >> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
    >> Boolean)
    >> If Intersect(Target, Range("B9")) Is Nothing Then
    >> Else
    >> MsgBox ("Hello Khizhavan")
    >> End If
    >> End Sub
    >>
    >>
    >> Because it is worksheet code, it is very easy to install and automatic to
    >> use:
    >>
    >> 1. right-click the tab name near the bottom of the Excel window
    >> 2. select View Code - this brings up a VBE window
    >> 3. paste the stuff in and close the VBE window
    >>
    >> If you have any concerns, first try it on a trial worksheet.
    >>
    >> If you save the workbook, the macro will be saved with it.
    >>
    >>
    >> To remove the macro:
    >>
    >> 1. bring up the VBE windows as above
    >> 2. clear the code out
    >> 3. close the VBE window
    >>
    >> To learn more about macros in general, see:
    >>
    >> http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >>
    >> To learn more about Event Macros (worksheet code), see:
    >>
    >> http://www.mvps.org/dmcritchie/excel/event.htm
    >>
    >> --
    >> Gary''s Student - gsnu200799
    >>
    >>
    >> "Khizhavan" wrote:
    >>
    >> > How to run macro in double click on a particular cell?
    >> >
    >> > let me know, how we can run a macro when i am pressing double click on
    >> > particular cell.
    >> >
    >> > Thanks
    >> >
     
    Don Guillett, Oct 6, 2008
    #5
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dr.Ile

    Run Macro when particular cell is changed?

    Dr.Ile, Nov 2, 2004, in forum: Microsoft Excel Programming
    Replies:
    0
    Views:
    182
    Dr.Ile
    Nov 2, 2004
  2. Guest

    How to call a sub defined in macro when double click a cell?

    Guest, Nov 18, 2005, in forum: Microsoft Excel Programming
    Replies:
    3
    Views:
    1,624
    Rowan Drummond
    Nov 20, 2005
  3. Run a macro after a particular cell changes...

    , Nov 18, 2006, in forum: Microsoft Excel Programming
    Replies:
    1
    Views:
    163
    Tom Ogilvy
    Nov 18, 2006
  4. Ronald Dodge
    Replies:
    1
    Views:
    217
    Peter T
    Nov 16, 2007
  5. Howard

    Double click fails to run the code, just selects the cell

    Howard, May 5, 2013, in forum: Microsoft Excel Programming
    Replies:
    12
    Views:
    441
Loading...

Share This Page