Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

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
If cell not null use that value Neall Excel Worksheet Functions 1 May 7th 09 07:55 PM
Failed to save table attributes of (null) into (null). Luca Brasi Excel Discussion (Misc queries) 2 February 4th 09 04:30 PM
Sum a NULL cell ArcticWolf Excel Worksheet Functions 6 December 4th 08 02:04 PM
cell value based on null/not null in another cell spence Excel Worksheet Functions 1 February 18th 06 11:49 PM
Cell to return null instead of 0 dford Excel Discussion (Misc queries) 7 November 28th 05 06:37 PM


All times are GMT +1. The time now is 07:20 AM.

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"