Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default ambiguous error

If you have multiple cells on the same worksheet that must be filled in, maybe
you could use something like:

Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim myRng As Range
Dim myCell As Range
Dim myMsg As String

Set myRng = Me.Worksheets("competency").Range("C3,d19")

myMsg = ""
For Each myCell In myRng.Cells
If Trim(myCell.Value) = "" Then
myMsg = myMsg & ", " & myCell.Address(0, 0)
End If
Next myCell

If myMsg < "" Then
myMsg = "Please Fill: " & Mid(myMsg, 3)
MsgBox myMsg
Cancel = True
End If

End Sub

=====
And just a thought, wouldn't this be better in the workbook_beforesave event?
If I open and want to close without saving, why should I have to fill in those
cells?



"jmorgs <" wrote:

The problem is that if I give it another name, like sheet_beforeclose,
or book_beforeclose the code won't work, but if I name is
workbook_beforeclose, because I have another cell with this exact same
code, I get this ambiguous error!
HELP!

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


--

Dave Peterson

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
ambiguous name detected? Derrick Excel Discussion (Misc queries) 7 July 8th 09 07:05 PM
Ambiguous error famdamly Excel Discussion (Misc queries) 1 February 27th 06 09:06 AM
ambiguous name detected mark Excel Programming 4 February 4th 04 03:01 PM
Ambiguous Name Detected Nigel[_5_] Excel Programming 11 October 26th 03 09:59 AM
Ambiguous Name Detected:~ jaf Excel Programming 0 September 12th 03 12:56 AM


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"