There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
VB - BeforeDoubleClick - I want to change Boolean value of Cancel


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Lori713's Avatar
Member with 42 posts.
 
Join Date: Sep 2003
Location: Raleigh, NC
15-Oct-2003, 11:51 AM #1
Question VB - BeforeDoubleClick - I want to change Boolean value of Cancel
I have a Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean) that contains instructions for certain cells/rows/columns to perform drilldowns after setting the default drilldown in the Insert,Name,Range box. This drilldown is part of PeopleSoft's nVision tool. However, I would like to stop the double-click event if the user double-clicks on a certain cell.

For example, if they double-click on cell A5, I want it to do nothing other than display a small MsgBox. If they double-click on cell B5, I want it to perform the stuff I have in my Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel As Boolean).

I read in the VB help file for the doubleclick event that:

Syntax 1

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

object: An object of type Chart declared with events in a class
module. For more information, see Using Events with the
Chart Object.

Target The cell nearest to the mouse pointer when the double-
click occurs.

Cancel False when the event occurs. If the event procedure
sets this argument to True, the default double-click
action isn't performed when the procedure is finished.

The Cancel section implies that the double-click action isn't performed, which is what I want for certain cells. But, I can't figure out how to change the value so that it thinks the argument is true. I hope this makes sense. Any ideas? Thanks!

Lori
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
15-Oct-2003, 12:22 PM #2
You should be able to do something like this...

Code:
If Not Application.Intersect(Target, Range("A5")) Is Nothing Then
  Cancel = True
Else
  'Perform normal actions
End If
First you check that they clicked in a cell you want to cancel the double click in, if they did, set Cancel = True (it will stop the double click from happening) otherwise perform the normal BeforeDoubleClick Event...
Lori713's Avatar
Member with 42 posts.
 
Join Date: Sep 2003
Location: Raleigh, NC
15-Oct-2003, 01:26 PM #3
Once I wedged it into my particular situation, it works like a charm! Thanks!!!
Gibble's Avatar
Distinguished Member with 27,137 posts.
 
Join Date: Oct 2001
Location: Striking or Scoring
Experience: The Alpha and Omega
15-Oct-2003, 02:02 PM #4
No problem
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:42 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.