注册 登录
编程论坛 Excel/VBA论坛

查找特定字符单元格并标明顺序?

newsoftware 发布于 2018-04-10 19:45, 2130 次点击
请教各位大神,如何用VBA查找特定字符单元格并自动标明顺序?

比如如下


只有本站会员才能查看附件,请 登录
1 回复
#2
xyxcc1772018-04-26 07:20
'自定义函数,用法:=GetNumValue(B2)
程序代码:

Public Function GetNumValue(ByVal rg As Range) As String
Dim strValue As String
Dim r, i, c, j As Integer
strValue = rg.Value
r = rg.Row
c = rg.Column
j = 0
For i = 1 To r
  If Cells(i, c).Value = strValue Then
    j = j + 1
  End If
Next
GetNumValue = "第" & j & "个:" & rg.Value
End Function
1