Results 1 to 12 of 12

Change Event based on two other cell values

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Change Event based on two other cell values

    myColumnOne = Range("NPN").Column 'this is column B, NPN is a Named Range of B1
    myColumnTwo = Range("NPCH").Column 'this is column E, NPCH is a Named Range of E1

    using these variables I want to say

    When data is entered into any cell in myColumnOne
    first check to see if this same data already exists in myColumnOne
    if it does then check to see if in the row where the data already exists, if the corresponding cell in myColumnTwo ISBLANK then MsgBox

    if the corresponding cell in myColumnTwo is not blank, allow the data to be entered.


    Example:
    Col B….Col E
    ABC…..xxx
    XZY…..

    It will allow ABC to be entered because Column E is populated
    It will not allow XYZ to be entered because Column E is blank, rather it will give a MsgBox alerting the user that the data already exists.

    Thank you, I've never done a Change Event before

    added & edited:

    I should also add that the data being entered into myColumnOne will be entered into the last cell (first blank) in the column.
    And that data may exist multiple times in the preceding cells, so each instance must be checked.

    I'm thinking that a For Next Loop to check the preceding cells for the data and a Offset to check the corresponding cell in myColumnTwo is what's needed. But then if it was some kind of a Do Until Loop, it would stop when it found a blank cell in myColumnTwo.

    Lastly, if it's even possible, it would find the existing data with the blank cell much faster if it searched from the bottom up instead of from row 1 down.
    Last edited by carsto; 05-09-2007 at 12:52 AM. Reason: added info

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