Double-click event question, part 2 (Excel 97)

B

Bob Wall

(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
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top