View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default Before Double Click

Target is just a range, like ActiveCell or Selection. For this macro, Target
is the range (cell) that was double-clicked.


Like any range, you can get its associated information:

Target.Address is its address (as a string)
Target.Column is its column number
Target.Row is its row number
Target.Value is its value

etc.

--
Gary's Student


"DaveyJones" wrote:

Excellent, cheers. I don't suppose you could explain the whole (ByVal Target
As Range, Cancel As Boolean) thing could you? I understand defining the
variable as boolean/range/integer etc, but the byVal and having to place them
in the brackets in a sub I don't understand.

--
Dave


"Gary''s Student" wrote:

How about:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Column = 1 Then
Cancel = True
Call dble(Target.Value)
End If
End Sub

Where dble is in a standard module.
--
Gary''s Student


"DaveyJones" wrote:

Private Sub Worksheet_BeforeDoubleClick(ByVal _
Target As Range, Cancel As Boolean)
Dim a As String, b, c
Cancel = True 'Get out of edit mode
a = ActiveCell
b = ActiveCell.Address
c = Range(b).Column
If b < "1" Then Exit Sub
Call dble(a)
End Sub

I looked on http://www.mvps.org/dmcritchie/excel/event.htm#change for ideas
and I copied some code and edited it to the above. Basically, I want to
contents of the cell that was double clicked on to be taken to sub dble. BUt
this should only happen if the cell clicked on was in column A. You can see
my attempt at doing this. For some reason it does not work though. When I
double click nothin happens. But when I get rid of my code it works fine. Any
suggestions...


--
Dave