在Excel中,如何使用相对引用计算行数?

时间:2018-04-23 23:05:24

标签: excel-vba excel-formula vba excel

对于SHEET2中的每个用户,如何计算SHEET1上COL1中出现“x”的次数?我试过COUNTIF,但我不知道如何使用相对引用,或者甚至可能。

SHEET1

    if(command === 'admin') {
        if(message.member.roles.find("name", "Owner")){
            var ServerExists = false;
             for(var ServerId; ServerId<Admins.length; ServerId++) {
                if(Admins[ServerId] === message.member.server.id) {
                    ServerExists = true;
                }
             }
             if(ServerExists === false) {
                var NewServer = Admins[Admins.length + 1]
                NewServer = {};
             }
             for(var ServerId; ServerId<Admins.length; ServerId++) {
                 if(Admins[ServerId] === message.member.server.id) {
                     var ServerNumber = ServerId
                 }
             }
            var ServerAdmins = Admins[ServerNumber]
            if(ServerAdmins[1]) {
                ServerAdmins[1] = message.member.server.id;
            } else {
            ServerAdmins[ServerAdmins.length + 1] = message.member.server.id;
            message.reply(`${ServerAdmins[ServerAdmins.length]} was added.`)
        }       
    }

SHEET2:

USER      COL1
user_a    x
user_a
user_b
user_b
user_c    x
user_c    x

1 个答案:

答案 0 :(得分:2)

使用COUNTIFS()

=COUNTIFS(Sheet1!A:A,A1,Sheet1!B:B,"x")

enter image description here