ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Double-click event question, part 2 (Excel 97) (https://www.excelbanter.com/excel-programming/309597-double-click-event-question-part-2-excel-97-a.html)

Bob Wall

Double-click event question, part 2 (Excel 97)
 
(Excel 97)
I have coded a double-click event to print a particular portion of an
employee schedule, but I'm having trouble making it work for more than the
first employee. This one works fine:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
' Print Employee 001

If Not Intersect(Target, Range("Empl001")) Is Nothing Then
Range("A8:O10").Select
Selection.PrintOut Copies:=1, Collate:=True
Cancel = True
End If
End Sub


When I try to add another employee in, it will not work:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
' Print Employee 001

If Not Intersect(Target, Range("Empl001")) Is Nothing Then
Range("A8:O10").Select
Selection.PrintOut Copies:=1, Collate:=True
Cancel = True
End If

' Print Employee 002

If Not Intersect(Target, Range("Empl002")) Is Nothing Then
Range("A14:O16").Select
Selection.PrintOut Copies:=1, Collate:=True
Cancel = True
End If
End Sub

It is in the same procedure... am I putting it in the wrong place? If I try
to create more than one double click event on the page I get an ambiguous
procedure name error... I have at least 20 employees that I need to
accommodate.

Any help is, as always, greatley appreciated!

BW



Tom Ogilvy

Double-click event question, part 2 (Excel 97)
 
Your code works fine for me in Excel 97.

The defined names are Empl (with an L) 001 and 002

Check to be sure. One might be Emp (then with a one) 1002

--
Regards,
Tom Ogilvy


"Bob Wall" wrote in message
...
(Excel 97)
I have coded a double-click event to print a particular portion of an
employee schedule, but I'm having trouble making it work for more than the
first employee. This one works fine:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
' Print Employee 001

If Not Intersect(Target, Range("Empl001")) Is Nothing Then
Range("A8:O10").Select
Selection.PrintOut Copies:=1, Collate:=True
Cancel = True
End If
End Sub


When I try to add another employee in, it will not work:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
' Print Employee 001

If Not Intersect(Target, Range("Empl001")) Is Nothing Then
Range("A8:O10").Select
Selection.PrintOut Copies:=1, Collate:=True
Cancel = True
End If

' Print Employee 002

If Not Intersect(Target, Range("Empl002")) Is Nothing Then
Range("A14:O16").Select
Selection.PrintOut Copies:=1, Collate:=True
Cancel = True
End If
End Sub

It is in the same procedure... am I putting it in the wrong place? If I

try
to create more than one double click event on the page I get an ambiguous
procedure name error... I have at least 20 employees that I need to
accommodate.

Any help is, as always, greatley appreciated!

BW






All times are GMT +1. The time now is 02:44 PM.

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