Consulting

Results 1 to 5 of 5

Thread: Stop if one of three conditions are true

  1. #1
    VBAX Regular
    Joined
    Dec 2004
    Posts
    26
    Location

    Stop if one of three conditions are true

    Hi Folks,
    I need to add a check to one of my printout macros.
    If cell G5 or cell H17 or cell B42 have no data, then the macro should stop.



    Any help appreciated.


  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hi,

    Add this to the top of your code where it's desired ...


    If IsEmpty([G5]) Or IsEmpty([H17]) Or IsEmpty([B42]) Then Exit Sub

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try the following


    Sub DoPrint()
    If [G5] = "" Or [H17] = "" Or [B42] = "" Then
        Exit Sub
    Else
        MsgBox "Do Printing"
    End If
    End Sub

  4. #4
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by outrider
    Hi Folks,
    I need to add a check to one of my printout macros.
    If cell G5 or cell H17 or cell B42 have no data, then the macro should stop.

    Any help appreciated.

    Assuming that I understand your criteria, try something like this:


    If Cells(5, 7) = "" Or Cells(17, 8) = "" Or Cells(42, 2) = "" Then
    MsgBox "stopping print macro because one or more key cells is blank"
    Exit Sub
    End If

  5. #5
    VBAX Regular
    Joined
    Dec 2004
    Posts
    26
    Location
    Thanks for all the help, it's really appreciated.

Posting Permissions

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