Hi Dan -
VBA does refer to ‘Target As Range’ because it is a range, but by default
rules of syntax for the BeforeDoubleClick procedure, it converts Target to
it’s value using ByVal. The conversion imparts a measure of protection
against unintentionally modifiying Target’s cell contents in the procedure.
You can’t modify the cells contents simply referring to ‘Target’. It must be
done explicitly somehow, ensuring that changes are intentional.
Modifying any component of the argument list results in an error. This is
the reason Nick stressed the technique of ‘letting excel create the routine
stubs.’ The VB editor sets the ground rules for the procedure by
automatically providing a syntax ‘boilerplate’; violating the boilerplate
ground rules results in errors.
That being said, once created, the procedure can be enhanced and copied as
long as you don’t edit the ‘boilerplate’ syntax. Below is a stab at your
latest specifications. Copy it to the proper worksheet module and modify the
range in the third line…
------------------------
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
Set containmentRng = Range("A1:A79") ' <==enter your sepcific range here.
Set isect = Application.Intersect(Cells(Target.Row, Target.Column),
containmentRng)
If isect Is Nothing Then
MsgBox "Double-clicked cell IS NOT inside containment range."
Else
MsgBox "Double-clicked cell IS inside containment range."
End If
End Sub