+ Reply to Thread
Results 1 to 8 of 8

VBA to create MsgBox based on Formula result

  1. #1
    Registered User
    Join Date
    06-10-2014
    Posts
    5

    VBA to create MsgBox based on Formula result

    Hi All.

    I have an Excel file where users can select from various dropdown lists (using data validation)

    I have year and month drop downs in cells F12 (Month) and F13 (Year) and on a separate tab I have a list of Year and Month combinations for which we do not have rates.

    I have entered a vlookup (G13) to check for the date combination and return "1" if it is found - I would like a Massage Box to pop up if the date is found in this list ie if the vlookup returns "1"

    I have managed to get the code below to work but only when "1" is hard typed into the cell - it doesn't work when the formula result = 1.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim A As Range
    Set A = Range("G13")
    If Intersect(Target, A) Is Nothing Then Exit Sub
    If Target.Value = 1 Then
    MsgBox "Rates for this broadcast period are not yet available"
    End If
    End Sub


    Does anyone have any idea how I can get it to work from the formula?

    Much appreciated!

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: VBA to create MsgBox based on Formula result

    just a guess....but the formula isn't returning exactly 1.....it might return 1.0000002....again, just a thought....
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA to create MsgBox based on Formula result

    formulas only run change events when you enter them first off. monitor the input cells instead
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Registered User
    Join Date
    06-10-2014
    Posts
    5

    Re: VBA to create MsgBox based on Formula result

    That worked perfectly!
    Thank you!!!

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA to create MsgBox based on Formula result

    you're welcome :-)

  6. #6
    Registered User
    Join Date
    06-10-2014
    Posts
    5

    Re: VBA to create MsgBox based on Formula result

    One more question - I need to apply the same thing to another set of dates further down on the page (they are completely unrelated), I have used the same code with updated cell references and I am getting the error message:

    Compile Error:
    Ambiguous name detected: Worksheet_Change

    I pasted the code onto the same VBA sheet as the last one as they are both running from the same worksheet - I'm guessing this may be the issue somehow.

    Again any help is greatly appreciated!

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA to create MsgBox based on Formula result

    you can only have one change event for a worksheet so you've gotta combine the code into one event

  8. #8
    Registered User
    Join Date
    06-10-2014
    Posts
    5

    Re: VBA to create MsgBox based on Formula result

    Thanks Joseph,

    I have edited the code so it now looks like this....

    Please Login or Register  to view this content.
    The first bit is still working fine but it doesn't seem to be picking up the changes to the second date formula.

    Apologies for being so clueless about all this! It's not something I have had much experience with.

    Thanks,

    Carrie

+ 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. Code to create result based on differnt cell ref. Split and total columns.
    By Kevin P in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2012, 11:37 AM
  2. msgbox popup when a formula result changes...
    By behemoth05 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-26-2009, 07:07 AM
  3. How to create a msgbox that show sum result of A1-A10 ?
    By yannipr in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-16-2008, 06:37 AM
  4. How to view function result in a msgbox ?
    By yannipr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2008, 01:45 PM
  5. Struggling With How to Create A Formula for Desired Result...
    By oxyron in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-01-2007, 03:36 PM
  6. Macro - msgbox vs. enter result in a cell??/
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2006, 08:09 PM
  7. Is it Possible to create a Message Box (MSGBOX) with Excel Formula?
    By Carlton in forum Excel Programming / VBA / Macros
    Replies: 36
    Last Post: 04-21-2005, 10:06 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