+ Reply to Thread
Results 1 to 8 of 8

If one cell in range is not empty, the all range must be not empty.

  1. #1
    Registered User
    Join Date
    07-27-2013
    Location
    Peru
    MS-Off Ver
    Excel 2003
    Posts
    24

    If one cell in range is not empty, the all range must be not empty.

    Hello
    I´m trying to do this in VB:
    If one (or any) cell in the range A1:A6 is not empty, then all range cells must be not empty.
    If not, cancel save and show msg box.

    Please help me.
    Regards
    Claudio.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: If one cell in range is not empty, the all range must be not empty.

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    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,197

    Re: If one cell in range is not empty, the all range must be not empty.

    Hiu, patel45,

    If not, cancel save and show msg box.
    This macro must be part of Workbook_BeforeClose-event - please read all the post carefully.

    @loroverde:
    adjust the name of the sheet to suit and place this code in ThisWorkbbok:
    Please Login or Register  to view this content.
    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

  4. #4
    Registered User
    Join Date
    07-27-2013
    Location
    Peru
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: If one cell in range is not empty, the all range must be not empty.

    Hello
    It works great as a macro, but i want to cancel before save if it doesn't accomplish the condition, I have used cancel=true but it doesn't work.
    how can I do this.
    Regards
    claudio.

  5. #5
    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,197

    Re: If one cell in range is not empty, the all range must be not empty.

    Hi. loroverde,

    sorry about my guess for a wrong event - maybe use Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) in Thisworkbook instead:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  6. #6
    Registered User
    Join Date
    07-27-2013
    Location
    Peru
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: If one cell in range is not empty, the all range must be not empty.

    Hello holger
    It works fine, but how can i do If one (or any) cell in the range A1:F1 and the cell H1 are not empty, then all range cells must be not empty.
    If not, cancel save and show msg box.


    Regards
    Claudio.

  7. #7
    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,197

    Re: If one cell in range is not empty, the all range must be not empty.

    Hi, Claudio,

    maybe like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  8. #8
    Registered User
    Join Date
    07-27-2013
    Location
    Peru
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: If one cell in range is not empty, the all range must be not empty.

    Hello holger
    How can i save this code with all the cells empty?
    Because with all the cells empty i cant save the workbook

+ 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. [SOLVED] Do only if Cell not empty on range
    By FallingDown in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-05-2013, 03:18 AM
  2. MACRO to empty a range of cells based on whether specified cell is empty
    By TBJV in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2013, 10:35 PM
  3. [SOLVED] Finding next empty empty cell in a range of columns
    By UncleBun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2006, 07:25 PM
  4. [SOLVED] Picking up the last non-empty cell in a given range
    By zhj23 in forum Excel General
    Replies: 4
    Last Post: 05-31-2005, 08:05 PM
  5. Next empty cell in range
    By Fraggs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-26-2005, 09:07 AM

Tags for this Thread

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