+ Reply to Thread
Results 1 to 14 of 14

Pop-up message if value for sum of cells exceeds a predefined number

  1. #1
    Registered User
    Join Date
    03-25-2015
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2013
    Posts
    43

    Pop-up message if value for sum of cells exceeds a predefined number

    Hello everyone,

    I have a document that has all of the dates in a year on the third row of the attached Excel file.

    i want a VBA script that pops-up a error message if the sum of a month exceedes a predifined value in another sheet.

    So if the sum of all of the days in January for Name 1 should not exceed the value from Sheet2 C3.

    This script should apply for all of the names (predifined number of row).

    Document attached.

    Thanks,
    -Alex
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    I think you can do this with data validation? Select C4:BI13 and try the following data validation formula:

    =SUMPRODUCT(--(MONTH($C$3:$BI$3)=MONTH(C$3)),$C4:$BI4)<=VLOOKUP(TEXT(C$3,"mmmm"),Sheet2!$B$3:$C$11,2,FALSE)

    Try the attachment to see if it works:
    Attached Files Attached Files
    If your problem has been solved, please use "Thread Tools" to mark the thread as "Solved".

    If you're grateful for this site's existence and would like to contribute to the community, please consider posting something hilarious in our joke thread:
    https://www.excelforum.com/the-water...ke-thread.html

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    Try this:

    Please Login or Register  to view this content.
    Last edited by xladept; 05-23-2018 at 04:05 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Registered User
    Join Date
    03-25-2015
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2013
    Posts
    43

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    Hello and sorry,

    I probably wasn't clear in my initial post.

    So the document will have number from 0 to 24 entered in the columns of each of the names (Name 1, Name 2 etc.).

    For example i would like to enter in cell K4 the value 6 and in the L4 the value 28, if we sum up all of the values for Name 1 we will get the number 34, but in Sheet 2 we have the month of January that has a maximum number of 30, which means that the document should show a pop-up mentioning that the sum of january for Name 1 is invalid due to the fact that it exceeds the number 30.

    Thanks,
    -Alex

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    So, try this:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    Quote Originally Posted by dLhx View Post
    For example i would like to enter in cell K4 the value 6 and in the L4 the value 28 [...] the document should show a pop-up mentioning that the sum of january for Name 1 is invalid due to the fact that it exceeds the number 30.
    I guess I'm still unclear on the goal? With the data validation approach, if you enter a 6 in K4, then attempt to enter a 28 in L4, you're blocked by the following pop-up:

    Isn't that what you're looking for?
    Attached Images Attached Images
    Last edited by CAntosh; 05-24-2018 at 10:35 AM.

  7. #7
    Registered User
    Join Date
    03-25-2015
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2013
    Posts
    43

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    @xladept : It works perfectly. Only one question. Is there a way that the VBA script could work continuous, meaning that if a single cell is changed the scripts will run automatically?

    I already gave everyone here a rep+ for helping me out with this :D

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    Here's event code for your Sheet1 module:

    Please Login or Register  to view this content.
    *After you paste it into your sheet1 module, you'll need to save the book as macro-enabled.

    And, you're welcome and thanks for the rep!

  9. #9
    Registered User
    Join Date
    03-25-2015
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2013
    Posts
    43

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    @xladept: Man i am so sorry for asking you this but apparently i am unable to do it myself for some unknown reason or maybe i`m just too bad at understanding VBA.

    I have attached the actual document that i need this script to work on (Testing Module.xlsx)

    Can you please help me out with this?

    Again, i`m so sorry for asking you to do this.
    Attached Files Attached Files

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    No attachment - but here's the book I used:
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    03-25-2015
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2013
    Posts
    43

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    The document was too big.

    Can you see it now?

    See my previous post for it.

    The range should be for the year .. January to December
    Last edited by dLhx; 05-24-2018 at 04:28 PM.

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    Here's the book back:
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    03-25-2015
    Location
    Bucharest, Romania
    MS-Off Ver
    Office 2013
    Posts
    43

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    YOU ARE A LIFE SAVER. Thank you so much!

  14. #14
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Pop-up message if value for sum of cells exceeds a predefined number

    You're welcome!

+ 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] UDF for concatenate predefined number of cells
    By jessko in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-12-2016, 02:08 PM
  2. [SOLVED] Copy Rows To Predefined Sheet Based on Date Range Using Form or Message Box
    By Isacc in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 02-06-2013, 09:25 AM
  3. Replies: 1
    Last Post: 05-03-2012, 10:50 AM
  4. Display a message when a Cell value exceeds 75% of the total allowed expenditure
    By chamdan in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-15-2011, 12:38 AM
  5. Replies: 3
    Last Post: 10-27-2008, 08:32 AM
  6. [SOLVED] counting if a value exceeds a specified number
    By Albert in forum Excel General
    Replies: 2
    Last Post: 07-20-2006, 09:20 AM
  7. Locate first number that exceeds reference value
    By Nick Krill in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-05-2006, 11:40 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