+ Reply to Thread
Results 1 to 3 of 3

Excel 2007 : msgbox popup in vba

  1. #1
    Registered User
    Join Date
    03-06-2011
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    4

    msgbox popup in vba

    I have this excel worksheet and wish to have msgbox popup if there is a value entered.
    example, in column A theres text "CASH" or "STOCK" or "#N/A", so in column B and C needs to put in value, so if its "CASH" value must be entered in column B and for "STOCK" value must be entered in column C.
    I want to be able to write vba to pick up that if its text in column A says "CASH" and I enter a value in column C instead of B then msgbox error should pop up warning me thats its in the wrong column.
    can someone please help???
    thank you sooo much!

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: msgbox popup in vba

    Hi AG,

    You can do this using Data Validation rather than VBA.

    Select B1:B10 and click Data > Data Validation > Data Validation. On the Settings tab, select 'Custom' from the first drop-down, and in the Formula textbox type:

    =A1="CASH"

    Un-check 'Ignore blank' if you don't want them to be able to enter anything into column B when column A for that row is blank. Click the Error Alert tab and set the Style drop-down to what you require. "Stop" will prevent them from entering data into those cells when the validation is not met (column A must say CASH). "Warning" will ask them if they want to keep the entry and continue even though it violates the validation, and "Information" will allow them to enter data after popping up just a warning that it violates the validation.

    Once you've selected a Style you can then customize the title and message for the pop-up.

    Repeat this for C1:C10, but change the formula to:

    =A1="STOCK"

    Hope that helps!

  3. #3
    Registered User
    Join Date
    03-06-2011
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: msgbox popup in vba

    whoa this is perfect! thank you so much for you help. however, it appears to be showing warning everytime, i just want it "IF" A is cash and I put value in STOCK then warning but for #N/A - no warning and no warning if text is CASH and I put value in CASH.

    in formulas, can i write something like "=IF range .... text "CASH" or "#N/A" then no warning ...etc... ???

    thank you so much!

    CASH STOCK
    CASH 1
    STOCK
    #N/A 1
    STOCK
    #N/A 2
    #N/A
    CASH

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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