+ Reply to Thread
Results 1 to 8 of 8

MsgBox dependant on sum and IF functionality

  1. #1
    Registered User
    Join Date
    01-04-2013
    Location
    Derby, England
    MS-Off Ver
    Excel 2003
    Posts
    64

    MsgBox dependant on sum and IF functionality

    Hi everyone,

    I've googled to my hearts content and can't find anything that could help me. It's been a very long time since I used VBA and so I can't remember much!

    What I require is a message box to pop up stating "Warning!" based on the sum of certain cells and if they are greater than the sum of other cells.

    E.G.

    If sum of A1+B1 is greater than sum of C1*D4, then Message box pops up.

    I know that the answer will be relatively simple but no matter how many hours I spend trying, I just can't seem to work it out!

    Thank you in advance,

    Kate

  2. #2
    Registered User
    Join Date
    08-01-2012
    Location
    Montreal, Qc, Canada
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: MsgBox dependant on sum and IF functionality

    Good Morning,

    I'd do something like this


    Please Login or Register  to view this content.
    If I helped, Don't forget to add to my reputation

  3. #3
    Registered User
    Join Date
    01-04-2013
    Location
    Derby, England
    MS-Off Ver
    Excel 2003
    Posts
    64

    Re: MsgBox dependant on sum and IF functionality

    Hi Steve,

    Thank you for your reply

    However I am unable to get it to work. I don't quite understand how it works?

    Kate

  4. #4
    Registered User
    Join Date
    08-01-2012
    Location
    Montreal, Qc, Canada
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: MsgBox dependant on sum and IF functionality

    sorry ... I just realized that i am missing your actual verification

    Also, This code should be placed in your "Sheet code" and not as a "Module"
    open your editor
    left hand side, double click the Sheet you want the code in
    change the drop down on the right code window from "General" to Worksheet
    place code here (the "SUB" should already be there.. just missing the code)

    let me know if that helps.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-04-2013
    Location
    Derby, England
    MS-Off Ver
    Excel 2003
    Posts
    64

    Re: MsgBox dependant on sum and IF functionality

    Hi Steve,

    Thank you for your reply .

    The above kind of does the job, but there is an odd delay, sometimes it takes a few clicks on different cells before the message box appears.

    Is there any way to make it instantaneous as soon as you hit enter on the value?

    Thanks again,

    Kate

  6. #6
    Registered User
    Join Date
    08-01-2012
    Location
    Montreal, Qc, Canada
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: MsgBox dependant on sum and IF functionality

    Right now I have it set to trigger only when cell "A1" or "B1" get selected. This is to prevent the msgbox from popping up if you need to change things in other cells.

    so its not a delay that you seeing. when you hit enter it is moving to the cell below and therefore not triggering the validation.

    Im sure there has to be away to validate only on exiting of the cell, but i cant figure it out.

    Sorry

  7. #7
    Registered User
    Join Date
    01-04-2013
    Location
    Derby, England
    MS-Off Ver
    Excel 2003
    Posts
    64

    Re: MsgBox dependant on sum and IF functionality

    Thanks Steve for your reply

  8. #8
    Registered User
    Join Date
    08-04-2009
    Location
    Golborne England
    MS-Off Ver
    2013
    Posts
    85

    Re: MsgBox dependant on sum and IF functionality

    Here try this. It will replace the code you have already placed in the worksheet code page.

    It will only trigger the message box if the values in cells A1,B2,C1 or D4 change and the sum of a1 and b1 is greater than c1 * d4.


    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)

Similar Threads

  1. [SOLVED] finding average with date dependant and cell dependant
    By sfoll in forum Excel General
    Replies: 4
    Last Post: 08-24-2015, 04:58 AM
  2. Macro to capture MsgBox prompt to a string variable but ignore the MsgBox
    By BuglerDobbs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-07-2015, 10:56 AM
  3. [SOLVED] Problem with VBA Editor uses lower case on some lines (ex. msgbox instead of MsgBox)
    By stubbsj in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-14-2013, 06:59 PM
  4. Dependant data validation with dependant default value
    By JamesMeek in forum Excel General
    Replies: 2
    Last Post: 04-08-2013, 10:16 AM
  5. Dependant Text in a MsgBox
    By bowhunt24 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-18-2011, 03:15 AM
  6. Replies: 0
    Last Post: 01-27-2010, 05:47 PM
  7. MsgBox-center the message on a msgbox
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-11-2007, 06:48 AM

Tags for this Thread

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