• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Validation on cells

I have created a button on my sheet to check for mandatory fields. I need to stop the user is they have entered data into cell F1 and F2. They can only enter data into one of the cells.
 
Hi Lesley ,

Why do you need code for this ?

Select the 2 cells F1 and F2 , and click on Data Validation , Custom , and enter the formula :

=OR(AND(ISBLANK(F$1),NOT(ISBLANK(F$2))),AND(ISBLANK(F$2),NOT(ISBLANK(F$1))))

This will prevent the user from entering data into both F1 and F2.

Either both F1 and F2 can be left blank , or data can be entered into either F1 or F2. Data cannot be entered into both F1 and F2.

However , the user can copy paste data into both cells overriding the data validation. If you want to prevent this , then you need to use code.

Narayan
 
Back
Top