![]() |
#1
|
|||
|
|||
![]()
I'm slowly getting more comfortable with VBA, but I frequently don't understand the logic in sample code that I find on the net. My present problem is understanding the event handling for a double click event.
The upper code is how I edited the sample code (which is commented out). Both seem to function the same. I understand the logic in my edited version, but not the logic in the sample: If the intercept is Nothing, doesn't that mean that target cell is not within the designated range? So why the "Not"? Why did the sample's author use the Not logic (I found a number of postings with this logic); does it have an advantage over my edited logic?I'd sincerely appreciate any comments that you can offer. Very respectfully, Larry Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) ' If the cell is not within the range B1:B10, then cancel ' If the cell is within the range, then act If Application.Intersect(Target, Range("B1:B10")) Is Nothing Then MsgBox ("is NOT in B1:B10") ' Action for out-of-range target Cancel = True Else: MsgBox ("is in B1:B10") ' Action if target is within the range End If ' Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) ' If Not Application.Intersect(Target, Range("C40")) Is Nothing Then ' Cancel = True ' SelectPayFreq.Show ' End If ' End Sub End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Event planning | cajos | Project | 3 | 03-26-2016 05:19 PM |
calendar event not showing | licinio | Outlook | 0 | 05-18-2015 05:27 AM |
![]() |
Tejas.T | Word VBA | 5 | 02-27-2015 08:01 PM |
Hyperlinks in Calendar Event? | komobu | Outlook | 0 | 07-16-2014 08:09 AM |
![]() |
groegee | Outlook | 1 | 12-05-2011 09:56 PM |