ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Detecting double click (https://www.excelbanter.com/excel-programming/382803-detecting-double-click.html)

kirkm[_6_]

Detecting double click
 
I'm using the following to launch some VBA when a cell is double
clicked.

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

Dim rng As Range
Dim MyLastRow As String

Set rng
=Worksheets("Sheet1").Range("A1").SpecialCells(xlC ellTypeLastCell)
MyLastRow = rng.Row

rows = "J1:J" & MyLastRow

If Not Intersect(Target, Range(rows)) Is Nothing Then
Cancel = True

********* Code here

End If


End Sub
++++++++++

Howver, I'd like to change that so any cell in the range S2 to CD5972
achieves the same result.

Is that possible?
Thanks - Kirk

Tom Ogilvy

Detecting double click
 
Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
Dim sAddr as String
sAddr = "S2:CD5972"
If Not Intersect(Target, Range(s)) Is Nothing Then
Cancel = True

********* Code here

End If
End Sub

--
Regards,
Tom Ogilvy

"kirkm" wrote in message
...
I'm using the following to launch some VBA when a cell is double
clicked.

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

Dim rng As Range
Dim MyLastRow As String

Set rng
=Worksheets("Sheet1").Range("A1").SpecialCells(xlC ellTypeLastCell)
MyLastRow = rng.Row

rows = "J1:J" & MyLastRow

If Not Intersect(Target, Range(rows)) Is Nothing Then
Cancel = True

********* Code here

End If


End Sub
++++++++++

Howver, I'd like to change that so any cell in the range S2 to CD5972
achieves the same result.

Is that possible?
Thanks - Kirk




Doug Glancy[_7_]

Detecting double click
 
Kirk,

Excuse me for horning in, but I believe Tom meant the line to be:

If Not Intersect(Target, Range(sAddr)) Is Nothing Then

hth,

Doug

"Tom Ogilvy" wrote in message
...
Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
Dim sAddr as String
sAddr = "S2:CD5972"
If Not Intersect(Target, Range(s)) Is Nothing Then
Cancel = True

********* Code here

End If
End Sub

--
Regards,
Tom Ogilvy

"kirkm" wrote in message
...
I'm using the following to launch some VBA when a cell is double
clicked.

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

Dim rng As Range
Dim MyLastRow As String

Set rng
=Worksheets("Sheet1").Range("A1").SpecialCells(xlC ellTypeLastCell)
MyLastRow = rng.Row

rows = "J1:J" & MyLastRow

If Not Intersect(Target, Range(rows)) Is Nothing Then
Cancel = True

********* Code here

End If


End Sub
++++++++++

Howver, I'd like to change that so any cell in the range S2 to CD5972
achieves the same result.

Is that possible?
Thanks - Kirk






kirkm[_6_]

Detecting double click
 
Thanks VERY much to both of you.

That's working wonderfully

Cheers - Kirk

Tom Ogilvy

Detecting double click
 
Yes I did. Thanks for the correction. That is the second time I have done
that <blush (this week).

--
Regards,
Tom Ogilvy

"Doug Glancy" wrote:

Kirk,

Excuse me for horning in, but I believe Tom meant the line to be:

If Not Intersect(Target, Range(sAddr)) Is Nothing Then

hth,

Doug

"Tom Ogilvy" wrote in message
...
Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
Dim sAddr as String
sAddr = "S2:CD5972"
If Not Intersect(Target, Range(s)) Is Nothing Then
Cancel = True

********* Code here

End If
End Sub

--
Regards,
Tom Ogilvy

"kirkm" wrote in message
...
I'm using the following to launch some VBA when a cell is double
clicked.

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

Dim rng As Range
Dim MyLastRow As String

Set rng
=Worksheets("Sheet1").Range("A1").SpecialCells(xlC ellTypeLastCell)
MyLastRow = rng.Row

rows = "J1:J" & MyLastRow

If Not Intersect(Target, Range(rows)) Is Nothing Then
Cancel = True

********* Code here

End If


End Sub
++++++++++

Howver, I'd like to change that so any cell in the range S2 to CD5972
achieves the same result.

Is that possible?
Thanks - Kirk







Doug Glancy[_7_]

Detecting double click
 
Well, I usually make tow typos in each anwser <g

Doug

"Tom Ogilvy" wrote in message
...
Yes I did. Thanks for the correction. That is the second time I have
done
that <blush (this week).

--
Regards,
Tom Ogilvy

"Doug Glancy" wrote:

Kirk,

Excuse me for horning in, but I believe Tom meant the line to be:

If Not Intersect(Target, Range(sAddr)) Is Nothing Then

hth,

Doug

"Tom Ogilvy" wrote in message
...
Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Range, Cancel As Boolean)
Dim sAddr as String
sAddr = "S2:CD5972"
If Not Intersect(Target, Range(s)) Is Nothing Then
Cancel = True

********* Code here

End If
End Sub

--
Regards,
Tom Ogilvy

"kirkm" wrote in message
...
I'm using the following to launch some VBA when a cell is double
clicked.

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

Dim rng As Range
Dim MyLastRow As String

Set rng
=Worksheets("Sheet1").Range("A1").SpecialCells(xlC ellTypeLastCell)
MyLastRow = rng.Row

rows = "J1:J" & MyLastRow

If Not Intersect(Target, Range(rows)) Is Nothing Then
Cancel = True

********* Code here

End If


End Sub
++++++++++

Howver, I'd like to change that so any cell in the range S2 to CD5972
achieves the same result.

Is that possible?
Thanks - Kirk









All times are GMT +1. The time now is 10:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com