+ Reply to Thread
Results 1 to 12 of 12

VBA - If Or Statement?

  1. #1
    Registered User
    Join Date
    06-24-2008
    Posts
    98

    VBA - If Or Statement?

    Hello,

    I want to create code that will check if a number of cells is empty and if they are to call a sub. If any of the cells are not empty then call another sub.

    I have tried using the following
    Please Login or Register  to view this content.
    But no matter what I try to do, I cannot add other cells.
    I hope that makes sence,
    Is anyone able to help?
    Last edited by Chris424; 11-30-2008 at 10:55 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this way

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    06-24-2008
    Posts
    98
    Thank you, How would I add other cells? Such as D18 and D19?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try

    Please Login or Register  to view this content.
    Or

    Please Login or Register  to view this content.
    To cjeck a single cell
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-24-2008
    Posts
    98
    Thanks again RoyUk but unfortunatly none of them seem to work?

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Attach the workbook

  7. #7
    Registered User
    Join Date
    06-24-2008
    Posts
    98
    Just to simplify it, I changed the Subs to MsgBoxes:
    Please Login or Register  to view this content.
    But if the box is empty or not it still gives the MsgBox "Empty"

  8. #8
    Registered User
    Join Date
    06-24-2008
    Posts
    98
    Thank you, :-)

    Its when clicking on the "New" command Button
    Attached Files Attached Files

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    The problem is that you are using MergedCells, these are generally to avoided because of the problems they cause. In effect the range is one cell

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    06-24-2008
    Posts
    98
    That works perfectly now for one cell thankyou.
    Is there a way of adding more than one cell
    If D21 or D19?
    Last edited by Chris424; 11-30-2008 at 12:04 PM.

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You are already checking D21, it's not clear what you are asking - check individual cells or a range?

    You code could be improved by removing the Selects like
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    You would also be better to use the sheet names with the ranges

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This will shorten the Clear code

    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