【发布时间】:2023-04-04 01:07:01
【问题描述】:
在尝试执行以下操作时,我总是收到类型不匹配错误或除以零错误:我只想计算一个范围内的唯一条目数,该范围内的条目是“类”文本:
startRow = 3
startColumn = 1
col = "A"
Set topCell = Cells(startRow, startColumn)
Set bottomCell = Cells(Rows.Count, startColumn)
If IsEmpty(bottomCell) Then Set bottomCell = bottomCell.End(xlUp)
Set selectRows = Range(col & topCell.Row & ":" & col & bottomCell.Row)
nRows = WorksheetFunction.CountA(selectRows)
test = WorksheetFunction.SumProduct(WorksheetFunction.IsText(selectRows) / WorksheetFunction.CountIf(selectRows, selectRows))
我在测试计算中有一个错误,但我不明白。非常感谢一些帮助
非常感谢
BR 马丁
【问题讨论】:
-
虽然
IsText会在工作表函数中使用Range对象,但我认为它不会在VBA 中接受Range?我一直在玩它,但无法在 VBA 中获得与工作表函数相同的行为
标签: vba range unique duplicate-removal