Thread: ambiguous error
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default ambiguous error

All procedures in a module must have unique names. The error
message is telling you that you already have a BeforeClose event
procedure in the ThisWorkbook module. Put your code in the
existing procedure rather than creating a new procedure with the
same name.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"jmorgs " wrote in
message ...
I have an Excel workbook which is a form that must be filled

out by
employees. I wrote code so that if a certain box is left empty

it will
not allow the workbook to be saved. The problem is that when I

tried to
copy and paste this code to another cell I get an error that

says
"ambiguous name detected, workbook_before close" My code is as

follows:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim j As Integer


If Trim(Me.Worksheets("competency").Range("C3").Value ) = ""

Then
MsgBox "Cell C3 is empty. Please fill it"
Cancel = True
Exit Sub
End If

End Sub

The problem is that I can't think of another name to name the

event so
this code will work.

Any help is appreciated!


---
Message posted from http://www.ExcelForum.com/