+ Reply to Thread
Results 1 to 4 of 4

If cell >0 then run the following code else msgbox

  1. #1
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    If cell >0 then run the following code else msgbox

    Hi.
    I have this following code:
    Please Login or Register  to view this content.
    But in the sheet where this code will run, called "DATA", i have 2 cells that shows a value according the data stored in other sheet. These two cells in DATA sheet are K17 and K21.
    What i want is that the code showned above only runs if K17 and K21 are greater than 0. If one of the cells are 0, or the two equals 0, the code should not run and display this message instead "The data is not avaiable. Please ait until more data is inserted and run the process again."

    So if someone could help i would be really appreciated. I guess i have to put an If condition in the code above first but i dont jnow how to do that.

    Thank you.

  2. #2
    Registered User
    Join Date
    09-13-2013
    Location
    London, England
    MS-Off Ver
    Excel 2011
    Posts
    12

    Re: If cell >0 then run the following code else msgbox

    Hi,

    Try something like this:

    Please Login or Register  to view this content.
    All I've done is create another routine that checks if K17 and K21 are greater than zero and if they BOTH are, then it runs the routine you defined in your post; otherwise it displays the error.

    I'm sure other forum members can create something more efficient but that's a quick way I'd do it. Hope it works!

    JD

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: If cell >0 then run the following code else msgbox

    Maybe:

    Please Login or Register  to view this content.
    Or

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    06-25-2012
    Location
    Porto, Portugal
    MS-Off Ver
    Excel 2010
    Posts
    201

    Re: If cell >0 then run the following code else msgbox

    Everyone works. Many thanks to both. Really helped. Thank you. Liked the two approaches.

+ 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. Workbook_Open code not firing unless MsgBox is in code
    By yay_excel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-09-2013, 03:11 PM
  2. Msgbox when cell contains certain value - code not working
    By rachel.dudley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2013, 09:31 AM
  3. VBA Code for msgbox
    By j.farr3ll in forum Excel General
    Replies: 4
    Last Post: 09-01-2011, 09:01 AM
  4. Add MsgBox to code
    By Phixtit in forum Excel General
    Replies: 2
    Last Post: 01-10-2010, 07:44 PM
  5. VBA code using if then and msgbox
    By snoopy in forum Excel General
    Replies: 0
    Last Post: 12-01-2005, 04:48 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