+ Reply to Thread
Results 1 to 3 of 3

Displaying a warning popup when a number is exceeded in a macro, before a Exit Sub

  1. #1
    Registered User
    Join Date
    04-12-2015
    Location
    UK
    MS-Off Ver
    2013
    Posts
    3

    Displaying a warning popup when a number is exceeded in a macro, before a Exit Sub

    Evening all,

    Could someone tell me how to get this macro to warn when J2 is greater than or = 230 but refuse to let the macro continue when it reaches 250 (J3), at the minute is still seems to allow the macro so copy the cells into the new sheet.

    Cheers

    Turly

    '
    Sheets("Booking").Select
    If Range("J3") > Range("J2") Then
    MsgBox "Sold Out, reduce number"
    Exit Sub
    End If
    Range("A20:S20").Select
    Selection.Copy
    Sheets("SavedBookings").Select
    Range("A2").Select
    Selection.End(xlDown).Select
    Range("A" & Rows.Count).End(xlUp).Offset(1).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Sheets("Booking").Select
    Range("B10").Select
    Application.CutCopyMode = False
    End Sub

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Displaying a warning popup when a number is exceeded in a macro, before a Exit Sub

    You need to enclose your code in code tags,

    Highlight your code and click on the # symbol in the menu bar

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    04-12-2015
    Location
    UK
    MS-Off Ver
    2013
    Posts
    3

    Re: Displaying a warning popup when a number is exceeded in a macro, before a Exit Sub

    Thank you for the code, it works great up to the 230 limit, however if someone was to place an order and buy 2 tickets when there is only 1 available it seems to allow the macro to push through and leave the total at -1 (231 tickets sold).

    Thank you also for your quick reply too!!

+ 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. Show warning sign if a value is exceeded
    By santa_man3 in forum Excel General
    Replies: 15
    Last Post: 03-31-2015, 09:46 AM
  2. [solved] Popup Warning after clicking Macro Button
    By MysticGenius in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-22-2011, 12:43 AM
  3. Macro for creating a popup warning dependant on cell value
    By mellis123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2011, 02:05 PM
  4. how to popup msgbox once exit ?
    By vumian in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-07-2006, 10:04 AM
  5. Add a warning popup to a Macro Button
    By Teresa in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-16-2006, 05:30 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