Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default adding restrictions on action Double_Click

The following code gives an action for double clicking on
a cell in a sheet.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As
Excel.Range, Cancel As Boolean)
MsgBox "You double clicked on cell " & Target.Address
Cancel = True
End Sub

Now I want to add a restriction with this action.
I want this code to work only for a specific range on the
sheet.

Is this possible?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default adding restrictions on action Double_Click

Using John Walkenbach's InRange function from
http://j-walk.com/ss/excel/tips/tip64.htm, you can do:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim oAllowableRange As Range
Set oAllowableRange = Sheet1.Range("A1:C3")
If InRange(Target, oAllowableRange) Then
MsgBox "That's fine."
Else
MsgBox "You're out of range."
Cancel = True
End If

End Sub

Function InRange(rng1, rng2) As Boolean
' Returns True if rng1 is a subset of rng2
InRange = False
If rng1.Parent.Parent.Name = rng2.Parent.Parent.Name Then
If rng1.Parent.Name = rng2.Parent.Name Then
If Union(rng1, rng2).Address = rng2.Address Then
InRange = True
End If
End If
End If
End Function





"Junior Trimon" wrote in message
...
The following code gives an action for double clicking on
a cell in a sheet.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As
Excel.Range, Cancel As Boolean)
MsgBox "You double clicked on cell " & Target.Address
Cancel = True
End Sub

Now I want to add a restriction with this action.
I want this code to work only for a specific range on the
sheet.

Is this possible?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default adding restrictions on action Double_Click

Place your code between this lines and it will only work
in the range A1:H20


If Not Application.Intersect(Range("A1:H20"), Target) Is Nothing Then


End If


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Junior Trimon" wrote in message ...
The following code gives an action for double clicking on
a cell in a sheet.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As
Excel.Range, Cancel As Boolean)
MsgBox "You double clicked on cell " & Target.Address
Cancel = True
End Sub

Now I want to add a restriction with this action.
I want this code to work only for a specific range on the
sheet.

Is this possible?



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
Excell copy action pauses for 15 second for the smallest action Meekal Excel Discussion (Misc queries) 1 January 28th 10 04:30 PM
Lookup restrictions lputnam Excel Discussion (Misc queries) 2 January 8th 10 04:29 PM
RESTRICTIONS YESHWANT JOSHI Excel Discussion (Misc queries) 5 May 26th 09 05:02 PM
Text Restrictions LPS Excel Worksheet Functions 3 September 25th 06 08:23 PM
How to do look up with restrictions JackR Excel Discussion (Misc queries) 3 April 3rd 06 01:12 AM


All times are GMT +1. The time now is 05:18 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"