![]() |
Cell not null value?
I am new to this VB macro stuff, so I am looking for a little help.
I have a worksheet that I want the user to NOT be able to leave certai fields blank. How do I create a macro that will do that and issue message box telling them that they must enter a value in this cell? I will have several cells that I want to check. Can this be done before they save and close the spreadsheet? Thanks d -- Message posted from http://www.ExcelForum.com |
Cell not null value?
One way is to not allow a close in the Workbook_BeforeClose event. Ge
to this section of code throught the VB editor and double-click on th ThisWorkbook module for your project. Paste something like this: Private Sub Workbook_BeforeClose(Cancel As Boolean) If Range("A1") = "" Then MsgBox "Data must be entered here before the worksheet can b closed." Range("A1").Select Cancel = True End If End Sub This is a pretty harsh way to go, and you might want to give them a out if they were not saving it. Maybe a messagebox warning? The Cancel = True is the part that disables the close. -- Message posted from http://www.ExcelForum.com |
All times are GMT +1. The time now is 08:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com