+ Reply to Thread
Results 1 to 5 of 5

How to check cell isnt blank upon saving or closing

  1. #1
    Registered User
    Join Date
    06-04-2008
    Posts
    13

    How to check cell isnt blank upon saving or closing

    I want to use the spreadsheet as form for users to fill out. Some cells require values to be entered. What would the code look like to perform a check when saving or closing that ensures certain cells (lets say a2 and b3) are not left empty

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try this in ThisWorkbook module

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    VBA Noob
    Last edited by VBA Noob; 09-25-2008 at 04:54 PM.
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    Earth
    MS-Off Ver
    2016
    Posts
    692
    Use the "on close" or "on save" event to do this when the user tries to do one of these actions. For either, within the VBA window, select ThisWorkbook and from the left drop down select Workbook and from right dropdown you'll see a list of possible events .. The ones you're suggesting are BeforeSave and BeforeClose. I suggest BeforeSave because the user may choose to close without completing the form and if you trap them there they won't be able to ... very annoying.

    So - selecting BeforeSave will give you the sub structure:
    Please Login or Register  to view this content.
    Here's a suggestion:
    Please Login or Register  to view this content.
    Hope that helps.
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top left of thread.

  4. #4
    Registered User
    Join Date
    08-22-2012
    Location
    Oslo, Norway
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How to check cell isnt blank upon saving or closing

    Could you expand on this a bit?
    If input is entered into column C (range C2:C100), then columns D, E ,F, H and I must not be blank upon save.
    An error msg pops up upon attempt to save and colors each cell yellow that lacks info yellow?

    ---------- Post added at 10:16 AM ---------- Previous post was at 10:15 AM ----------

    Sorry...I'm using Excel 2010.

  5. #5
    Registered User
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,147

    Re: How to check cell isnt blank upon saving or closing

    ScottyDo,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. User form to display adjacent cell value and move to next blank cell
    By Ketel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2008, 03:15 PM
  2. How? Ignore cell if blank in an IF formula.
    By n2lectual in forum Excel General
    Replies: 7
    Last Post: 03-26-2008, 03:46 PM
  3. closing a workbook without saving and closing a workbook with saving enabled
    By stanigator in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2007, 02:15 PM
  4. saving excel files by cell data automatically
    By Henry83 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2007, 08:26 AM
  5. "sum" returns spooky hidden decimal figures
    By joshstyx in forum Excel General
    Replies: 9
    Last Post: 12-01-2006, 08:01 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1