Hi ,
The reason for using the AND operator is because the test is for inequality.
Suppose you wish to test for equality ; the test would then be :
If a sheet name is equal to name1 OR a sheet name is equal to name2
Suppose we have three sheets named name1 , name2 and name3.
For the tab named name1 , the above IF statement would return a TRUE result , since this name satisfies the first test , and since an OR statement returns TRUE if any of its components is TRUE , the IF statement will return TRUE.
For the tab named name2 , the above IF statement would return a TRUE result , since this name satisfies the second test.
For the tab named name3 , the above IF statement would return a FALSE result , since this name satisfies neither the first test nor the second test.
Thus , when testing for equality , generally , an OR combination is used.
When you test for inequality , the test is as follows :
If a sheet name is not equal to name1 AND a sheet name is not equal to name2.
With the same three sheets , for the tab named name1 , the above IF statement would return a FALSE result , since this name does not satisfy the first test , and since an AND statement returns FALSE if any of its components is FALSE , the IF statement will return FALSE.
For the tab named name2 , again the above IF statement would return a FALSE result , since this name satisfies the first test but does not satisfy the second test.
For the tab named name3 , the above IF statement would return a TRUE result , since this name satisfies the first test (it is not equal to name1) , and it satisfies the second test (it is not equal to name2) and since an AND statement returns TRUE if all of its components are TRUE , the IF statement will return TRUE.
Thus , generally when testing for inequality , we use the AND operator.
Narayan