+ Reply to Thread
Results 1 to 6 of 6

HELP: VBA that prompt message before close when certain cell is less than 100

  1. #1
    Registered User
    Join Date
    05-27-2020
    Location
    singapore
    MS-Off Ver
    2013
    Posts
    11

    HELP: VBA that prompt message before close when certain cell is less than 100

    Hi, i am new to marco. i need to some help that can make the file prompt up message (when saving the file), lets say cell E10 the total is less than 100.
    I tried many online sample but it does not prompt.

    i tried following sample online but nothing prompt

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Range("E10").Value > 100 Then
    MsgBox "Try again total is not 100"
    End If
    End Sub

    Thank you in advance!!

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    897

    Re: HELP: VBA that prompt message before close when certain cell is less than 100

    Try to place the below into the Workbook module (ThisWorkbook):


    EDIT: previous version was triggers when closing. This on when saving.

    Please Login or Register  to view this content.
    Note: the formula checks only if E10 is greater than 100. The message box is stating 'in not 100'...
    Last edited by ORoos; 05-27-2020 at 04:03 AM.

  3. #3
    Registered User
    Join Date
    05-27-2020
    Location
    singapore
    MS-Off Ver
    2013
    Posts
    11

    Re: HELP: VBA that prompt message before close when certain cell is less than 100

    Hi, thank you! it works!! i realised i paste to the wrong sheet. btw is it possible to make it unable to save when is less than 100? Because currently it still allow to save even with the pop up. Thank you
    Last edited by feidifeidi; 05-27-2020 at 04:23 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    897

    Re: HELP: VBA that prompt message before close when certain cell is less than 100

    The below will prevent saving if E10 is greater than 100. Give it a try...

    Please Login or Register  to view this content.
    Last edited by ORoos; 05-27-2020 at 04:44 AM.

  5. #5
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2016
    Posts
    897

    Re: HELP: VBA that prompt message before close when certain cell is less than 100

    ...your heading is "cell is LESS than 100'...The formula/code is >100 GRATER than 100. Depending on what your requirements are you may need to change the > to <.

  6. #6
    Registered User
    Join Date
    05-27-2020
    Location
    singapore
    MS-Off Ver
    2013
    Posts
    11

    Re: HELP: VBA that prompt message before close when certain cell is less than 100

    Hi!
    i need some help to change the code. Below is the current code with one condition only. I want to add one more condition. which is i want range F1 to Q1 if any value is more than 0 but less than 99.9 it will prompt the msg too. is it possible? Thank you in advance!!

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

    If Sheet1.Range("E30").Value < 99.9 Then
    MsgBox "Monthly total is less than 99.9."
    End If

    End Sub

+ 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] VBA Prompt to close PDF so file can be overwrtitten or close automatically
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2014, 12:31 PM
  2. Value Enter Cell Value - If match value in a range then prompt message box
    By llc0606 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-03-2013, 05:33 AM
  3. Warning message. And changing data without close message.
    By pinguino in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2013, 03:01 PM
  4. [SOLVED] Compare cell values of different Workbooks and prompt message using macro
    By jericlapuz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-21-2012, 03:42 AM
  5. Replies: 0
    Last Post: 12-21-2012, 03:19 AM
  6. [SOLVED] vba-password prompt on close
    By kikde in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-15-2005, 09:40 AM

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