Raj,
I can only say "it worked for me" (XP, XL2002). Setting Cancel to true
should cancel the default double-click action (ie. going into edit mode).
Do you by any chance have an (eg) XL add-in which might also be capturing
the doubleclick event from the sheet ?
If you wanted the cell to remain unchanged if the user cancels, then remove
the lines.
Else
Target.Value = ""
If you're still having problems then I can mail you my test file. My email
is
t i m j williams at g mail dot co m (no spaces)
Tim
Hi Tim,
I tried the code. As it did not work, I modified it as shown under:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
Dim s
If Not Application.Intersect(Target, Me.Range("b2")) Is Nothing Then
'If Target.Row = 1 And Target.Column = 2 Then
s = Application.GetOpenFilename()
If s <> False Then
Target.Value = s
Else
Target.Value = "" 'clear on cancel ?
End If
Cancel = True
Else
Cancel = False
End If
End Sub
As the modification was cosmetic, I did not expect it to work. It
didn't.
Now the actual behaviour: When I double-click in cell B2, it opens for
editing (which is the default behaviour of double-clicking in a cell).
Has some code to be written to disable this default behaviour.
Incidentally, I have double-checked that the code is in the right work
worksheet, macros are enabled and application.enableevents = True
Please Help.
Thanks and Regards,
Raj