+ Reply to Thread
Results 1 to 5 of 5

If the range A1:F1 and the cell H1 are not empty, then all range cells must be not em

Hybrid View

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

    If the range A1:F1 and the cell H1 are not empty, then all range cells must be not em

    Hello
    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.

  2. #2
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: If the range A1:F1 and the cell H1 are not empty, then all range cells must be not em

    try with this..

    Sub tst()
    If Evaluate("OR(ISBLANK(A1:F1),ISBLANK(H1))") Then
        MsgBox "One of the cell is empty'"
    Else
        MsgBox "All are filled"
    End If
    End Sub
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

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

    Re: If the range A1:F1 and the cell H1 are not empty, then all range cells must be not em

    Hello
    The problem with this sub is than i that it cancel save when all the cells are empty, and I only want to cancel when one (ore more) of the cells is or are not empty and the other ones are empty.

    If all are empty or all not empty do not cancel, in other case, cancel.

  4. #4
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: If the range A1:F1 and the cell H1 are not empty, then all range cells must be not em

    Cancel is a part of many eventtrigger macro..

    What Trigger you are using..

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: If the range A1:F1 and the cell H1 are not empty, then all range cells must be not em

    Hello loroverde,

    Do it this way:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
    With Sheet1
    If Evaluate("OR(ISBLANK(A1:F1),ISBLANK(H1))") Then
    Cancel = True
        MsgBox "One or all of the cells are empty. Saving has been Cancelled"
    Else
    Cancel = False
        MsgBox "All Cells are filled, WorkBook will now be Saved", vbOKOnly, ("Contol Check")
        
    End If
    End With
    End Sub
    Attached Files Attached Files
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

+ 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. how to copy a range of cells, paste them and then find next empty cell
    By comp23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-01-2013, 03:34 PM
  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] How to add 1 to a calculated cell if a range of cells are not empty?
    By Bandolin in forum Excel General
    Replies: 3
    Last Post: 10-27-2012, 04:24 PM
  4. shift range of cells to left if find the range of empty do while
    By farrukh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2012, 09:25 AM
  5. 2 Input Box into 2 cells in the next empty cell in a range
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-16-2009, 01:32 PM

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