+ Reply to Thread
Results 1 to 10 of 10

Can someone help me apply this if statement to a range of cells

  1. #1
    Registered User
    Join Date
    03-19-2013
    Location
    new hampshire
    MS-Off Ver
    Excel 2010
    Posts
    37

    Can someone help me apply this if statement to a range of cells

    Here is the current if statement

    Please Login or Register  to view this content.
    I would like to apply it to A1:A2000. I'm fairly new and haven't been able to figure it out. Thank you in advance.
    Last edited by mk3ll00; 05-31-2013 at 02:31 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Can someone help me apply this if statement to a range of cells

    One way, maybe:

    Please Login or Register  to view this content.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    03-19-2013
    Location
    new hampshire
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Can someone help me apply this if statement to a range of cells

    Thank you for the quick response. The cells in column A have formulas in them they will return "", 1, or 3 depending on another range of cells.
    I tried your suggestion but I'm getting an error message popup even when the cell in column A is blank?

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Can someone help me apply this if statement to a range of cells

    The code as provided will display a MsgBox if ANY cell in the range A1:A2000 has, or returns, a value of 1 or 3. This check will happen when you change ANY cell on the worksheet. So, if you have a formula in the range that returns a 1, say, you'll get a pop-up message. If you click OK, the MsgBox will go but, as soon as you change any other cell, it carries out the check again and displays the Box. To not get the MsgBox displayed, you would have to clear the value either by deleting it or bu changing the input to the formulae taht generate the values.

    Maybe I have mis-interpreted your requirement. What, exactly, do you want to happen when you have values of 1 and/or 3 in column A?


    Regards, TMS

  5. #5
    Registered User
    Join Date
    03-19-2013
    Location
    new hampshire
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Can someone help me apply this if statement to a range of cells

    I would like to create a couple different error messages that can pop up depending on the value that shows up. Even if every cell in column AA is blank which it currently is I'm still getting the error message when ever I alter the range of cells that are linked to column AA. In case I'm not explaining that well let's say column B is the column linked to AA. I type in the word stop into B1 which would promt cell AA1 to have a value of "". In this case I don't want an error message to pop up but it seems to be even if there isn't a value of 1 or 3 in the entire AA range

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Can someone help me apply this if statement to a range of cells

    Please post a sample workbook.

    Regards, TMS

  7. #7
    Registered User
    Join Date
    03-19-2013
    Location
    new hampshire
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Can someone help me apply this if statement to a range of cells

    Polycast.xlsm

    Column H is the column they will enter the function into. Column AA feeds from that.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Can someone help me apply this if statement to a range of cells

    OP: paragraph after the code excerpt:

    I would like to apply it to A1:A2000.
    That's the range that the code checks ... A1:A2000.

    Looking at your sample, every row in column A has a 1 in it, hence you will get pop-ups.

    Change the rCheck range from A1:A2000 to AA1:AA2000 and it should do what you want.

    And maybe you should split the IF ... ELSEIF ... END IF otherwise if you have both issues it will only highlight type 1 errors.

    Please Login or Register  to view this content.

    Regards, TMS

  9. #9
    Registered User
    Join Date
    03-19-2013
    Location
    new hampshire
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Can someone help me apply this if statement to a range of cells

    whoops, right you are. I didn't notice it was set to column A instead of AA. Thank you very much for the help

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Can someone help me apply this if statement to a range of cells

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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