if cell is empty

Posted on 2014-08-08
Last Modified: 2014-08-08
There are numerous replies on EE for this but not the exact one I need.

If A2 is blank I want to put out a message to say cell is blank and then I want to Exit Sub.

If A2 is not blank I need to continue to the next piece of code.

I have code tosay if blank but I can't sus out how to put out the message and then move to next piece of code.

Question by:Jagwarman
    LVL 47

    Accepted Solution



    Sub YourCode()
    'first part of your code

    if Range("A2") = "" Then
        MsgBox "Cell is blank"
        Exit Sub

    End If

    'second part of your code

    End Sub


    Author Comment

    so easy I must have tried every combination except that one Doh! Thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
    INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
    The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now