如果公式比较两列

时间:2017-10-05 19:59:56

标签: excel-formula

需要一个公式,说明第3栏和第3栏中的信息组合。同一行中的4个匹配第1列和第1列的组合。 2在同一行然后说YES,否则说No。第5列显示我想看到的内容。第1列中有一个橙色,第2列中有2222222,所以它显示为NO,因为第I列中的香蕉在第2列中有2222222。

Example

FIRST SET OF VALUES             SECOND SET OF VALUES                
COLUMN 1    COLUMN 2        COLUMN 3   COLUMN 4 COLUMN 5        
ORANGE          11111111        ORANGE     22222222 NO      
BANANA          22222222        BANANA     22222222 YES     
PEAR            33333333        PEAR       55555555 NO      
PEAR            44444444        WATERMELON 55555555 YES     
WATERMELON  11111111        GRAPES     66666666 YES     
WATERMELON  55555555        PEACH      33333333 YES     
GRAPES          66666666        PLUM       44444444 NO      
GRAPES          77777777        PINEAPPLE  34343434 YES 
GRAPES          22222222                            
PEACH           33333333                        
PLUM            88888888                            
PLUM            77777777                            
PINEAPPLE   99999999                            
PINEAPPLE   12121212                            
PINEAPPLE   34343434                            
PINEAPPLE   56565656                            

1 个答案:

答案 0 :(得分:0)

使用COUNTIFS():

import java.util.*;

public class countInt {
    static int N;
    static int c;

    public countInt() {
        Scanner kn = new Scanner(System.in);
        System.out.println("Please type in a number between 10 - 1000");
        N = kn.nextInt();
    }

    public static void main(String[] args) {
        String New = Integer.toString(N);
        int NewLength = New.length();

        for (int i=0; i <= NewLength; i++){
            if (New.charAt(i) == '3'){
                c++;
            }
        }

        System.out.println("The number contains " + c + "number 3's");
    }
}

enter image description here

相关问题