+ Reply to Thread
Results 1 to 5 of 5

Checking cell for 2 conditions

  1. #1
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196

    Checking cell for 2 conditions

    Good Morning!

    I have this code that checks 2 cells for data. If data is in cell A1, but not B1 a message box pops up, "Cell B1 has no code". This part of the code works fine.

    If both cells has the information needed, how do I return a message box that
    says, "Check Sheet Sucessful".

    I'm using a macro button on the sheet to check these conditions:

    Code:

    Sub Check_click()
    If Range("A1").Value <> "" And Range("B1").Value = "" Then
    MsgBox "Please enter a code in the 1st box, under code in Special Purpose Deposits. Click Ok and type General or Building!", 16, "message"
    Range("B1").Select
    End If
    If Range("A1").Value = "" And Range("B1").Value = "" Then
    MsgBox "Successful!", 16, "message"
    End If
    End Sub


    By the way, I don't get any errors. If B1 if left empty, I get the first message box, and it goes to the cell. If I leave cell B1 blank, then run the macro, nothing happens, the screen just blinks, like something did.

    Thanks,
    EMoe

  2. #2
    Valued Forum Contributor
    Join Date
    07-11-2004
    Posts
    851
    I think your problem is that an empty cell does not have the value of "". Maybe test for value of 0 (zero) if you are looking for an empty cell.
    not a professional, just trying to assist.....

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Perhaps just this
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    05-09-2005
    Location
    SC
    Posts
    196
    Thanks for the speedy replies!

    I can see it now with your help. I tried Nories first, and it worked. Now I'll try Duane's for learning purposes.

    Thanks,
    EMoe

  5. #5
    Tom Ogilvy
    Guest

    Re: Checking cell for 2 conditions

    > I think your problem is that an empty cell does not have the value of
    > "".


    Activecell.ClearContents
    ? isempty(ActiveCell)
    True
    ? ActiveCell.Value = ""
    True
    ? activeCell.Value = 0
    True

    Guess it does have a value of "", but zero seems to work as well.

    --
    Regards,
    Tom Ogilvy


    "duane" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I think your problem is that an empty cell does not have the value of
    > "". Maybe test for value of 0 (zero) if you are looking for an empty
    > cell.
    >
    >
    > --
    > duane
    >
    >
    > ------------------------------------------------------------------------
    > duane's Profile:

    http://www.excelforum.com/member.php...o&userid=11624
    > View this thread: http://www.excelforum.com/showthread...hreadid=374525
    >




+ 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