+ Reply to Thread
Results 1 to 4 of 4

Macro to check the empty Cells in a row before closing the file

  1. #1
    Forum Contributor
    Join Date
    11-04-2012
    Location
    Czech Republic
    MS-Off Ver
    MS 365
    Posts
    260

    Cool Macro to check the empty Cells in a row before closing the file

    Hi everyone :-)

    I have a tricky question - do you know, if there is a possibility to have macro which will check my cells in one specific column before file is closed? Could anyone help me to update macro as follows:

    - to see in message box in which row is empty cell
    - to show message before file is closed when "Close File" button is pressed? So when I close the excel file message will pop up?

    My macro is:

    Sub IsCellBlank()
    If IsEmpty(Range("AD")) Then
    MsgBox "Empty cell in row 125. Please correct and chose the right root cause"
    End If
    End Sub


    Thank you lot

    Andy :-)
    Last edited by dobracik; 07-09-2013 at 03:04 PM.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro to check the empty Cells in a row before closing the file

    Hi, Andy,

    please wrap code-tags around the procedure you show in the opening post - thank you.

    Maybe like this:
    Please Login or Register  to view this content.
    You should alter the name of the sheet to check. Code could either be called in the Workbook_BeforeClose/BeforeSave-event (first should be cancelled if an empty cell is shown) or in the Worksheet_Deactivate-event.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Macro to check the empty Cells in a row before closing the file

    suppose the file is a saved file. open the file
    open vb editor (alt F11)
    click control+R
    all the open files will be listed.
    choose this file unde this file right click "thisworkbook" and click view code
    in the widow that comes up copy paste this EVENT CODe and save the file
    now when you close the file (click x at top right) pop up message will come and act on that.

    Please Login or Register  to view this content.
    Last edited by venkat1926; 07-06-2013 at 07:29 AM.
    I am not an expert. better solutions may be available
    [email protected]

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro to check the empty Cells in a row before closing the file

    Hi, venkat1926,

    two things: I doubt it to be a good idea to let the user close a file and tell the person to open it agiain (you´re always following everything what you have been told?). That´s what the Cancel = True should take care of.

    And I pretty much expect the message for blanks to appear on every closing of the file as you search the entire column instead of just the range with data. You can overcome that in filling out each cell in Column AD beneath the used range.

    Ciao,
    Holger

+ 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