Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
If cell not null use that value | Excel Worksheet Functions | |||
Failed to save table attributes of (null) into (null). | Excel Discussion (Misc queries) | |||
Sum a NULL cell | Excel Worksheet Functions | |||
cell value based on null/not null in another cell | Excel Worksheet Functions | |||
Cell to return null instead of 0 | Excel Discussion (Misc queries) |