+ Reply to Thread
Results 1 to 8 of 8

How to check adjacent cell for value and display error message for certain conditions

  1. #1
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    How to check adjacent cell for value and display error message for certain conditions

    Hi all,

    as roster coordinator for my workplace, I usually handle all the allocation of overtime when it arises. I was on vacation just recently, however, and a couple of other supervisors incorrectly allocated some overtime. To get around that human error, I've been trying to code something that would check cell values and throw up a message box if certain conditions were met. I've been trying a sheet change event using offset but without much luck so I'm hoping someone can point me in the right direction. Basically I'm trying to achieve this...

    Range of cells is A4 to AA42

    If a user enters a value of "L" or "OL" into the sheet, it should check the cell immediately to the left, and if it finds a value of "N" or "ON', throw up the message box. Conversely, if a user enters "N' or "ON' into a cell, it should check the cell immediately to the right for a value of "L" or "OL", and if found, throw up a message box.

    Thanks in advance for any suggestions,

    AJ
    Last edited by ScotyB; 05-01-2017 at 07:59 PM. Reason: to mark as solved
    Always grateful for the help here - thanks.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: How to check adjacent cell for value and display error message for certain conditions

    If a user enters a value of "L" or "OL" into the sheet, it should check the cell immediately to the left
    Hi ScotyB,

    If we're in cell A4 you can't check to the immediate left so what's the rule there?

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: How to check adjacent cell for value and display error message for certain conditions

    How about this for starters ?

    Please Login or Register  to view this content.
    Last edited by bakerman2; 05-01-2017 at 07:33 PM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    Re: How to check adjacent cell for value and display error message for certain conditions

    Lol, my bad, Trebor - it should have been B4 - I've just finished a night shift and was tired...

    Good pickup - ta

    AJ

  5. #5
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,527

    Re: How to check adjacent cell for value and display error message for certain conditions

    Hi AJ,

    Seems like bakerman2 has already come up with a nifty solution

    Robert

  6. #6
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    Re: How to check adjacent cell for value and display error message for certain conditions

    Thanks, bakerman, have just tried that and it works a treat.

    Much appreciated,

    AJ

  7. #7
    Forum Contributor
    Join Date
    08-04-2010
    Location
    Adelaide, Australia
    MS-Off Ver
    Office 365
    Posts
    176

    Re: How to check adjacent cell for value and display error message for certain conditions

    Indeed, trebor, but thanks for taking the time to have a look - appreciated.

    AJ

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: How to check adjacent cell for value and display error message for certain conditions

    You're welcome and thanks for rep+.

+ 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. Display error message if cell has no value
    By callum91 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-20-2015, 10:40 AM
  2. Display ActiveCell and Adjacent Cell Values in message Box
    By Tellm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2015, 12:16 PM
  3. Replies: 3
    Last Post: 06-19-2014, 06:07 PM
  4. Muliple Conditions to Check in a table to display value in a cell
    By Kapil Gosain in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-10-2013, 03:36 AM
  5. VBA - Check 3 rows if blank and display text in one of them in adjacent cell
    By guitalex in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2012, 09:32 AM
  6. Replies: 2
    Last Post: 12-18-2009, 05:20 PM
  7. How to display a blank cell with no error message
    By Juco in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-31-2005, 05: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