PC Review


Reply
Thread Tools Rate Thread

how to run macro in double click on a particular cell

 
 
Khizhavan
Guest
Posts: n/a
 
      11th Aug 2008
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

 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      11th Aug 2008
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
>

 
Reply With Quote
 
 
 
 
RocketRod
Guest
Posts: n/a
 
      6th Oct 2008
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
> >

 
Reply With Quote
 
RocketRod
Guest
Posts: n/a
 
      6th Oct 2008
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
> >

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      6th Oct 2008
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
(E-Mail Removed)
"RocketRod" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> 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
>> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Double click right mouse not a double click Freddy Windows XP Internet Explorer 5 23rd Jan 2008 11:12 AM
in vba what command is used to determine if a particular cell on a particular sheet changed? some kind of event? how to get the old and new value of the cell? Daniel Microsoft Excel Worksheet Functions 1 23rd Jun 2005 07:53 PM
in vba what command is used to determine if a particular cell on a particular sheet changed? some kind of event? how to get the old and new value of the cell? Daniel Microsoft Excel Discussion 1 23rd Jun 2005 07:44 PM
Double click event invoked when no double click has occurred Michael Matuszak Microsoft Access Forms 0 6th Aug 2004 03:51 PM
No Double-Click event fired for a ListView when I double click. active Microsoft VB .NET 1 26th Nov 2003 06:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:01 AM.