PC Review


Reply
Thread Tools Rate Thread

Cancel = True not turning edit feature off

 
 
=?Utf-8?B?VG9mZXJLaW5n?=
Guest
Posts: n/a
 
      18th Jul 2007
I have been goofing around with both of these codes, thanks to the help of
you guys here and in my research I see that the Cancel = True line is in the
coding to tell Excel not to go into edit mode when a cell is double-clicked.

Well, when I double-click in the target range of cells B3 to B8, Excel is
going into Edit mode.

What am I doing wrong?

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

Cancel = True
If Not Intersect(Target, Range("B3:B8")) Is Nothing Then
If Target = "P" Then
Target = vbNullString
ElseIf Target = vbNullString Then
Target = "P"
Else
End If
End If

End Sub

OR


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
With Target
If Not Intersect(.Cells, Range("B3:B8")) Is Nothing Then
If IsEmpty(.Value) Then
.Value = "P"
Else
.ClearContents
End If
End If
End With
End Sub

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9mZXJLaW5n?=
Guest
Posts: n/a
 
      18th Jul 2007
Just got it to work.

I saved and closed the workbook and then reopened it and it started working.



"ToferKing" wrote:

> I have been goofing around with both of these codes, thanks to the help of
> you guys here and in my research I see that the Cancel = True line is in the
> coding to tell Excel not to go into edit mode when a cell is double-clicked.
>
> Well, when I double-click in the target range of cells B3 to B8, Excel is
> going into Edit mode.
>
> What am I doing wrong?
>
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> Boolean)
>
> Cancel = True
> If Not Intersect(Target, Range("B3:B8")) Is Nothing Then
> If Target = "P" Then
> Target = vbNullString
> ElseIf Target = vbNullString Then
> Target = "P"
> Else
> End If
> End If
>
> End Sub
>
> OR
>
>
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> Boolean)
> Cancel = True
> With Target
> If Not Intersect(.Cells, Range("B3:B8")) Is Nothing Then
> If IsEmpty(.Value) Then
> .Value = "P"
> Else
> .ClearContents
> End If
> End If
> End With
> End Sub
>

 
Reply With Quote
 
Vasant Nanavati
Guest
Posts: n/a
 
      18th Jul 2007
Glad it's working. I would advise against using the IsEmpty version, though.
It doesn't mean what you would think it means (even if it works).
__________________________________________________________________________



"ToferKing" <(E-Mail Removed)> wrote in message
newsAABC5D1-C65C-4D5A-9C84-(E-Mail Removed)...
> Just got it to work.
>
> I saved and closed the workbook and then reopened it and it started
> working.
>
>
>
> "ToferKing" wrote:
>
>> I have been goofing around with both of these codes, thanks to the help
>> of
>> you guys here and in my research I see that the Cancel = True line is in
>> the
>> coding to tell Excel not to go into edit mode when a cell is
>> double-clicked.
>>
>> Well, when I double-click in the target range of cells B3 to B8, Excel is
>> going into Edit mode.
>>
>> What am I doing wrong?
>>
>> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
>> Boolean)
>>
>> Cancel = True
>> If Not Intersect(Target, Range("B3:B8")) Is Nothing Then
>> If Target = "P" Then
>> Target = vbNullString
>> ElseIf Target = vbNullString Then
>> Target = "P"
>> Else
>> End If
>> End If
>>
>> End Sub
>>
>> OR
>>
>>
>> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
>> Boolean)
>> Cancel = True
>> With Target
>> If Not Intersect(.Cells, Range("B3:B8")) Is Nothing Then
>> If IsEmpty(.Value) Then
>> .Value = "P"
>> Else
>> .ClearContents
>> End If
>> End If
>> End With
>> End Sub
>>



 
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
Cancel = True Sam Kuo Microsoft Excel Programming 4 12th Jun 2008 01:03 AM
CancelEventArgs.Cancel - How Event Raising Code Know if Client Set .Cancel=true Smithers Microsoft C# .NET 3 24th Sep 2007 02:30 AM
Cancel = true Stapes Microsoft Access 1 18th Jul 2007 04:48 PM
Cancel = True Stapes Microsoft Access 1 18th Jul 2007 04:45 PM
Cancel = True =?Utf-8?B?SnVzdEJyZWF0aGU=?= Microsoft Excel Programming 4 9th Apr 2007 04:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:46 AM.