Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default double click macros

Here's what doesn't work. How do I correct It so both macros work on
different ranges? The error message I get is: Ambiguous name detected
They both work independently but not on the same project.

Option Explicit

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

Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("c7:c57")) Is Nothing Then
With Target
If .Value = "X" Then
.Value = ""
Else

.Value = "X"

End If
End With
Cancel = True
End If
sub_exit:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim Rng1 As Range

'Assign the range to work with
Set Rng1 = Range("D7:D57")

'Only work on assigned range
If Intersect(Target, Rng1) Is Nothing Then Exit Sub

'Cancel cell editing that would normally trigger when you double click
Cancel = True

'Call the userform
UserForm1.Show

End Sub

"jack" wrote in message
...
Can someone help me on how I can set up two different double click macros
(two different resulting actions) on the same worksheet for different
ranges. I have each macro starting with: Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean). I
found very quickly that it doesn't work. What do I need to do so that
each will work independently?
Any basic direction would be appreciated.




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default double click macros

Try this
Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)

If Not Intersect(Target, Range("c7:c57")) Is Nothing Then
With Target
If .Value = "X" Then
.Value = ""
Else
.Value = "X"
End If
End With
Cancel = True
End If
'Assign the range to work with
'Only work on assigned range
If Intersect(Target, Range("D7:D57")) Is Nothing Then Exit Sub

'Cancel cell editing that would normally trigger when you double click
Cancel = True

'Call the userform
UserForm1.Show




End Sub

"jack" wrote:

Here's what doesn't work. How do I correct It so both macros work on
different ranges? The error message I get is: Ambiguous name detected
They both work independently but not on the same project.

Option Explicit

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

Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("c7:c57")) Is Nothing Then
With Target
If .Value = "X" Then
.Value = ""
Else

.Value = "X"

End If
End With
Cancel = True
End If
sub_exit:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim Rng1 As Range

'Assign the range to work with
Set Rng1 = Range("D7:D57")

'Only work on assigned range
If Intersect(Target, Rng1) Is Nothing Then Exit Sub

'Cancel cell editing that would normally trigger when you double click
Cancel = True

'Call the userform
UserForm1.Show

End Sub

"jack" wrote in message
...
Can someone help me on how I can set up two different double click macros
(two different resulting actions) on the same worksheet for different
ranges. I have each macro starting with: Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean). I
found very quickly that it doesn't work. What do I need to do so that
each will work independently?
Any basic direction would be appreciated.





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default double click macros

Thanks Mike, that worked for me


"Mike" wrote in message
...
Try this
Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)

If Not Intersect(Target, Range("c7:c57")) Is Nothing Then
With Target
If .Value = "X" Then
.Value = ""
Else
.Value = "X"
End If
End With
Cancel = True
End If
'Assign the range to work with
'Only work on assigned range
If Intersect(Target, Range("D7:D57")) Is Nothing Then Exit Sub

'Cancel cell editing that would normally trigger when you double click
Cancel = True

'Call the userform
UserForm1.Show




End Sub

"jack" wrote:

Here's what doesn't work. How do I correct It so both macros work on
different ranges? The error message I get is: Ambiguous name detected
They both work independently but not on the same project.

Option Explicit

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

Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Range("c7:c57")) Is Nothing Then
With Target
If .Value = "X" Then
.Value = ""
Else

.Value = "X"

End If
End With
Cancel = True
End If
sub_exit:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Dim Rng1 As Range

'Assign the range to work with
Set Rng1 = Range("D7:D57")

'Only work on assigned range
If Intersect(Target, Rng1) Is Nothing Then Exit Sub

'Cancel cell editing that would normally trigger when you double
click
Cancel = True

'Call the userform
UserForm1.Show

End Sub

"jack" wrote in message
...
Can someone help me on how I can set up two different double click
macros
(two different resulting actions) on the same worksheet for different
ranges. I have each macro starting with: Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean).
I
found very quickly that it doesn't work. What do I need to do so that
each will work independently?
Any basic direction would be appreciated.







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
double click macros Mike Excel Programming 0 September 26th 07 04:40 AM
double click macros Mike Excel Programming 0 September 26th 07 04:32 AM
double click macros Alok[_3_] Excel Programming 0 September 26th 07 04:27 AM
Click on graph bar to execute a double-click in a pivot table cell [email protected] Charts and Charting in Excel 4 August 3rd 05 01:37 AM
Mouse Over Graph, Capture Information on Click(Double Click) Dean Hinson[_3_] Excel Programming 1 December 6th 04 04:49 AM


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