Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Code Question

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Code Question

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim rng As Excel.Range
Set rng = Me.Range("S2:CD5972")

If Not Intersect(Target.Cells(1, 1), rng) Is Nothing Then
Cancel = True
'********* Code here
Else
'do something else?
End If
Set rng = Nothing
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vb code question Stan Excel Discussion (Misc queries) 0 April 28th 08 04:43 PM
vb code question Stan Excel Discussion (Misc queries) 1 April 25th 08 09:45 PM
question on VB code peyman Excel Discussion (Misc queries) 6 October 22nd 07 11:47 PM
code question Ana Excel Programming 1 May 2nd 06 10:49 AM
code question Gary Keramidas[_2_] Excel Programming 16 July 19th 05 05:13 PM


All times are GMT +1. The time now is 05:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"