excel - 查找 COUNTIFS 函数的地址(单元格/行)

标签 excel function

我有一个 Excel 文件,其中填充了大量 COUNTIFS 函数(超过 300 个)。这些公式工作正常,但我需要能够找到每个 COUNTIFS 结果的地址,因为数据源非常大。

即如果 COUNTIFs 给我所选参数的结果为 1,我需要能够知道函数正在从数据源中计数哪个单元格/行。

我认为这可以使用 ADDRESS 函数来完成,但我不确定如何将其与 COUNTIFS 一起使用。

最佳答案

我会使用用户定义的函数。

使用下面的代码,您将得到以下结果: enter image description here

Public Function ListAddresses(SearchTerm As Variant, SearchRange As Range) As String
    Dim WS As Worksheet, rCell As Range

    Set WS = Sheets(SearchRange.Parent.Name)
    SearchTerm = UCase(SearchTerm)

    Set SearchRange = Intersect(WS.UsedRange, SearchRange)

    For Each rCell In SearchRange.Cells
        If UCase(rCell.Value) = SearchTerm Then
            ListAddresses = ListAddresses & rCell.Address(False, False) & " | "
        End If

    Next rCell

    If ListAddresses <> "" Then
        ListAddresses = Left(ListAddresses, Len(ListAddresses) - 3)
    Else
        ListAddresses = "<none>"
    End If

End Function

关于excel - 查找 COUNTIFS 函数的地址(单元格/行),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51028036/

相关文章:

excel - 以编程方式将图片插入单元格注释中

c++ - 递归函数错误

python - Cython 函数指针解引用时间(与直接调用函数相比)

javascript - 函数应该在 jQuery 的扩展内部还是外部?

c++ - C++模板类-继承调用错误的函数

vba - Excel 宏 : Copy sheet without links - just data

vba - Excel VBA - 双击时将列中所有选定的单元格大写

c# - 使用 ExcelDataReader 从特定单元格开始读取 Excel 数据

vba - 不使用剪贴板是否可以实现VBA功能?只设置所有工作表值

python - 在函数之间建立多个持久 HTTP 连接