嵌套最小选择 | Excel-VBA UDF参数
Nested Min Selection | Excel-VBA UDF Parameters
Excel 2015/访问 2015
主要函数:LavenshteinDistance return一个整数
Function LDCellsTwo(sR As Range, tR As Range, IDRange As Range) As Integer
Dim tRNum As Integer: Dim CLVD As Integer: Dim MinLVD As Integer: Dim MinID As Integer
For tRNum = 0 To tR.Count
CLDV = LevenshteinDistance(sR.Text, tR(tRNum))
if IsEmpty(MinLDV) then MinLDV = CLDV + 1
If CLDV < MinLDV Then
MinLDV = CLDV
MinID = IDRange(tRNum)
End If
Next tRNum
LDCellsTwo = MinID
End Function
已编辑:感谢 Scott 的好收获 - 仍然导致#NAME?错误
目标:让 LDCellsTwo 函数 return 与第一个最低 LevenshteinDistance 值关联的 ID 值 return 通过针对 t
范围内的单个值迭代范围内的各个项目sR
范围,其中 ID
范围和 t
范围隐含相同的长度
错误:#NAME?
returned in cell
不确定为什么这会产生如此大的影响,但是
Function LDCellsTwo(sR As Range, tR As Range, IDRange As Range) As Integer
Dim tRNum As Integer: Dim CLVD As Integer: Dim MinLVD As Integer: Dim MinID As Integer
For tRNum = 1 To tR.Count
CLDV = LevenshteinDistance(sR.Text, tR(tRNum))
if IsEmpty(MinLDV) then MinLDV = CLDV + 1
If CLDV < MinLDV Then
MinLDV = CLDV
MinID = IDRange(tRNum)
End If
Next tRNum
LDCellsTwo = MinID
End Function
变化是:
来自 For tRNum =
0To tR.Count
到For tRNum =
1To tR.Count
Excel 2015/访问 2015
主要函数:LavenshteinDistance return一个整数
Function LDCellsTwo(sR As Range, tR As Range, IDRange As Range) As Integer
Dim tRNum As Integer: Dim CLVD As Integer: Dim MinLVD As Integer: Dim MinID As Integer
For tRNum = 0 To tR.Count
CLDV = LevenshteinDistance(sR.Text, tR(tRNum))
if IsEmpty(MinLDV) then MinLDV = CLDV + 1
If CLDV < MinLDV Then
MinLDV = CLDV
MinID = IDRange(tRNum)
End If
Next tRNum
LDCellsTwo = MinID
End Function
已编辑:感谢 Scott 的好收获 - 仍然导致#NAME?错误
目标:让 LDCellsTwo 函数 return 与第一个最低 LevenshteinDistance 值关联的 ID 值 return 通过针对 t
范围内的单个值迭代范围内的各个项目sR
范围,其中 ID
范围和 t
范围隐含相同的长度
错误:#NAME?
returned in cell
不确定为什么这会产生如此大的影响,但是
Function LDCellsTwo(sR As Range, tR As Range, IDRange As Range) As Integer
Dim tRNum As Integer: Dim CLVD As Integer: Dim MinLVD As Integer: Dim MinID As Integer
For tRNum = 1 To tR.Count
CLDV = LevenshteinDistance(sR.Text, tR(tRNum))
if IsEmpty(MinLDV) then MinLDV = CLDV + 1
If CLDV < MinLDV Then
MinLDV = CLDV
MinID = IDRange(tRNum)
End If
Next tRNum
LDCellsTwo = MinID
End Function
变化是:
来自 For tRNum =
0To tR.Count
到For tRNum =
1To tR.Count