+ Reply to Thread
Results 1 to 4 of 4

Save and close file if there is text in cells

  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    Brussels
    MS-Off Ver
    Excel 2010
    Posts
    16

    Save and close file if there is text in cells

    I do have the below code to safe a file and close it:

    Sub Save_Close()
    '
    ' Save_Close Macro
    '
    '
    ActiveWorkbook.Save
    Application.Quit
    End Sub



    I would like to do additionally something else. I need a macro to do the above, but it should first check if cells A2:C9 do contain text. The text could be anything.
    If there is text in ALL the cells, then the macro should save and close the file. If there is text missing in at least one of the cells, a message box should appear saying 'Please fill out all cells'.

    Can somebody help?

    Thanks

  2. #2
    Registered User
    Join Date
    07-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007/2010
    Posts
    86

    Re: Save and close file if there is text in cells

    Try
    Please Login or Register  to view this content.
    Boon

  3. #3
    Registered User
    Join Date
    06-14-2012
    Location
    Brussels
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Save and close file if there is text in cells

    Thank you...It is working. :-)
    I have one more question though.
    I realized though that sometimes the range will change. What I mean is that if I have say rows 2 to 9 and columns A to C that can be filled out in my worksheet "Data1" with data, the user may need to fill out only rows 2 to5. The requirement though is that all columns A to C must be filled out. So not necessarily all rows must be filled out, but all columns.
    Also if one datapoint is filled out in a row, say A2, but B2 and C2 are left out, I also need the message box "Please fill out all cells" to appear.

    Thank you

  4. #4
    Registered User
    Join Date
    07-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2007/2010
    Posts
    86

    Re: Save and close file if there is text in cells

    Try this
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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