在EXCEL中获取列中不重复的值的个数-.NET教程,数据库应用
来源:作者: 发布时间:2007-12-26 02:04:20

public sub distinctcount()
求col列中startrow到endrow范围中不重复的个数
本例是计算标题为sheet1的excel表中的a1:a240的不重复值的个数
修改下面四行的结尾值
dim sheetscaption as string: sheetscaption = "sheet1"
dim col as string: col = "a"
dim startrow as integer: startrow = 1
dim endrow as integer: endrow = 240
以下固定
dim count as integer: count = 0
with sheets(sheetscaption)
for i = startrow to endrow
count = count + 1
for j = startrow to i - 1
if .range(col & i) = .range(col & j) then
count = count - 1
exit for
end if
next
next
end with
msgbox count
end sub
|
还没有关于此文章的相关评论!