| 发表于:2007-07-11 09:25:331楼 得分:0 |
sub my_countif() dim dat() xx = inputbox( "请输入一个条件! ", "查找 ", " ") if len(xx) > = 1 then i = activesheet.usedrange.rows.count j = activesheet.usedrange.columns.count redim dat(1 to i * j) n = 0 for each c in activesheet.range(cells(i, j).address & ": " & cells(1, 1).address) if c.value = xx then n = n + 1 dat(n) = cells(c.row + 1, c.column) end if next x = 0 for i = 1 to n if x = 5 then s_string = s_stirng & dat(i) & chr(10) x = 0 else s_string = s_string & dat(i) & " " x = x + 1 end if next msgbox "合计找到 " & n & " 个符合条件的记录!分别如下: " & chr(10) & s_string end if end sub | | |
|