+ Reply to Thread
Results 1 to 7 of 7

Simple msgbox fix

  1. #1
    Registered User
    Join Date
    04-17-2013
    Location
    Napa, California
    MS-Off Ver
    Excel 2007
    Posts
    15

    Simple msgbox fix

    I have a warning on a sheet:

    Please Login or Register  to view this content.
    How do I insert the exitproc or whatever I need for when the reference cell "G1" is >4 or else? G1 is a day count down so the value is either >4, <4, or "Done"

    Technically it could even read #VALUE when the template is blank.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Simple msgbox fix

    You need to post the whole code. What you have makes no sense. TARGET is usually set by worksheet event handlers.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    04-17-2013
    Location
    Napa, California
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Simple msgbox fix

    Ok, here you go. The first half is for a separate change function

    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Simple msgbox fix

    1. Set R2 = Range("m1:m1") is only one cell and is the same as Set R2 = Range("m1")

    2. Because R2 is a single cell, Set intersectrange = Application.Intersect(R1, R2) will only return a range if the target is M1

    Since every everything seems to be dependent on the target being M1 you can do that with a single line:

    If Target.Address(0,0) ="M1" Then

    { do code based on target being M1 }

    Else

    { do code based on target elsewhere }

    End If

    Exit Sub

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

    Re: Simple msgbox fix

    using intersect is better since you can change multiple cells at once

    I don't see the issue-there is no need or an else or exit sub there-if the value is not less than 20 nothing will happen
    Josie

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

  6. #6
    Registered User
    Join Date
    04-17-2013
    Location
    Napa, California
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Simple msgbox fix

    Ok, now I'm really confused and I'm sure it's mostly my fault.

    This is intended to be its own code for a separate issue on the sheet.
    Please Login or Register  to view this content.
    This is the code I'm trying to work in on the same sheet.
    Please Login or Register  to view this content.
    So I cannot combine the two different change functions? Maybe I'm calling them the wrong thing?

    I think I just need to work on the formula in the reference cell so it never reads anything but an integer.
    Last edited by Javajawa16; 04-19-2013 at 10:25 AM.

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

    Re: Simple msgbox fix

    your additional code would just be
    Please Login or Register  to view this content.
    if you are checking g1 on the same sheet as the code

+ 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