Subcount()
DimRngAsRange
Dimi&,Col&,Fist,Last
Dimcount
SetRng=Application.InputBox("请选择单列数据列!",Type:=8)
'用户选择数据列
SetRng=Intersect(Rng.Parent.UsedRange,Rng)
'intersect语句避免用户选择整列造成无谓运算
Col=Rng.Column'Rng所在列
Fist=Rng.Row
'Rng开始行,用户选择的区域并不是一定从第一行开始,因此需要此句判断
Last=Fist+Rng.Rows.count-1'Rng结束行
Application.ScreenUpdating=False'取消屏幕更新
Application.DisplayAlerts=False
'取消消息提醒。当有值单元格被合并时屏蔽提示信息
Rng.Parent.Select'激活Rng对象所在的工作表,避免跨工作表操作问题
count=1
Fori=LastToFist+1Step-1
'对Rng进行从后向前遍历
IfCells(i,Col)<>Cells(i-1,Col)Then
Cells(i,Col+1)=count
count=1
ElseIfCells(i,Col)=Cells(i-1,Col)Then
count=count+1
EndIf
Next
EndSub
一、解读
1、range.row
range(b52:b57).Row52
range(b52:b57).Rows.count 6
如果觉得《统计同一列中出现次数 次数不累计计算 并标注》对你有帮助,请点赞、收藏,并留下你的观点哦!