![]() |
exit cell automatically after entering data
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 P.S. I posted this yesterday (Mar 19 2008) and someone was kind enough to respond, but Microsoft's link (in the auto-generated e-mail to me) to the response did not work. I thank that individual for responding, and ask that you please re-send your answer. |
exit cell automatically after entering data
Put this in your ThisWorkbook code module. To access the VBA editor, press
Alt + F11. On the left you will see the Project window with sheet1, sheet2, etc. and ThisWorkbook listed. Double click ThisWorkbook then copy and paste this code into the big window. Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) RETRY: userName = InputBox("Enter your first and last name.", "USER NAME") If userName = False Or UserName = "" Then MsgBox "You must enter your name to close this file." GoTo RETRY: End If Range("E59") = userName End Sub When the user attempts to close the workbook, this code will run and will not let them close until they enter something in the input box. Of course, they can always use someone else's name. "Patrick Riley" wrote: 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 P.S. I posted this yesterday (Mar 19 2008) and someone was kind enough to respond, but Microsoft's link (in the auto-generated e-mail to me) to the response did not work. I thank that individual for responding, and ask that you please re-send your answer. |
All times are GMT +1. The time now is 01:42 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com