View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Patrick Riley Patrick Riley is offline
external usenet poster
 
Posts: 34
Default Require specific cell entry before saving file

Thank you, Nigel. I placed the code in the "ThisWorkbook" code sheet, but it
did not work (I still could save the file with cell E59 being blank. I then
substituted the name of the worksheet (Main) for "Sheet1", but that did not
work, either.

"Nigel" wrote:

Place the following code in the "ThisWorkbook" code sheet........

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Len(Trim(Sheet1.Range("E59"))) = 0 Then
MsgBox "Enter name in cell E59 before save", vbCritical + vbOKOnly
Cancel = True
End If
End Sub

--

Regards,
Nigel




"Patrick Riley" wrote in message
...
I want to require the user to enter his/her name in a specific cell (E59)
before the user can save the file.
I tried using Data Validation where I specified Text Length between 1 and
40, and left blank the check-box for "Ignore Blank". Nope. I never
programmed in VBA, so I hope there is a simple solution (I might be OK
with
some simple VBA code).
---Pat