te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>vba - Excel macro to find how many values are in column C with same combination of values in column A and B - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vba - Excel macro to find how many values are in column C with same combination of values in column A and B - Stack Overflow

programmeradmin3浏览0评论
C1 C2 C3 C4 (expected result)
comp1 sql 12 test1 1
comp2 sql 12 test2 1
comp3 sql 13 test3 2
comp3 sql 13 test4 2
comp3 sql 14 test1 1
comp4 sql 12 test6 2
comp4 sql 12 test7 2
comp4 sql 13 test1 3
comp4 sql 13 test2 3
comp4 sql 13 test3 3
C1 C2 C3 C4 (expected result)
comp1 sql 12 test1 1
comp2 sql 12 test2 1
comp3 sql 13 test3 2
comp3 sql 13 test4 2
comp3 sql 14 test1 1
comp4 sql 12 test6 2
comp4 sql 12 test7 2
comp4 sql 13 test1 3
comp4 sql 13 test2 3
comp4 sql 13 test3 3

I have a data similar to above. I need a macro to check how many values are in column C3 , corresponding to each combination of C1 and C2. Example, in row 1, for combination of comp1 and sql 12 --> we have only one value in column C3. Hence the result expected in C4 is 1. Row 3 and Row 4, we have 2 values responding comp3 and sql 13 combination. Hence the expected result in C4 is 2

Can someone please help to achieve this

Share Improve this question edited Feb 17 at 12:58 Dominique 17.5k19 gold badges78 silver badges144 bronze badges asked Feb 17 at 12:24 doubtingdoubting 71 silver badge7 bronze badges 1
  • 4 Looks like COUNTIFS would achieve this. – Darren Bartrup-Cook Commented Feb 17 at 12:51
Add a comment  | 

1 Answer 1

Reset to default 1

As Darren suggest in the comments: Use the CountIfs-function. The formula for your example would be =COUNTIFS($A$2:$A$11;A2;$B$2:$B$11;B2). It counts how often the value of A2 is in column A (A2:A11) and how often the value of B2 is in column B. Enter the formula into C2 and copy it down.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论