查找Excel工作表中的所有数组公式

发布于 2024-11-06 03:34:43 字数 34 浏览 3 评论 0原文

有没有办法找到给定Excel电子表格中的所有数组公式?

is there a way to find all array formulas in a given excel spreadsheet?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜未央樱花落 2024-11-13 03:34:43

看一下这个例子。希望有帮助。

Sub array_formula()
Dim rRange As Range, cell As Range
Dim tot As Integer
Set rRange = ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas)
    For Each cell In rRange
        If cell.HasArray Then
            MsgBox cell.Address & " " & cell.formula
            tot = tot + 1
         End If
     Next cell
MsgBox "total number of array formula: " & tot
End Sub

Take a look at this example. Hope that it helps.

Sub array_formula()
Dim rRange As Range, cell As Range
Dim tot As Integer
Set rRange = ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas)
    For Each cell In rRange
        If cell.HasArray Then
            MsgBox cell.Address & " " & cell.formula
            tot = tot + 1
         End If
     Next cell
MsgBox "total number of array formula: " & tot
End Sub
苍暮颜 2024-11-13 03:34:43

对现有的(我发现非常有用,谢谢)进行了轻微升级,它将搜索所有工作表。

Sub debug_print_array_formulas_all_sheets()
    Dim ws As Worksheet
    Dim rRange As Range, cell As Range
    Dim tot As Integer

    For Each ws In ThisWorkbook.Sheets
        On Error GoTo NotFound
        ws.Unprotect
        Dim v As Variant
        v = ws.UsedRange.HasFormula
        If IsNull(v) Or v Then

            Set rRange = ws.UsedRange.SpecialCells(xlCellTypeFormulas)
            tot = 0
            For Each cell In rRange
                If cell.HasArray Then
                    Debug.Print ws.Name & ":" & cell.Address & " " & cell.Formula
                    tot = tot + 1
                End If
             Next cell
             If tot > 0 Then
                Debug.Print "total number of array formula on " & ws.Name & ": " & tot
                tot = 0
             End If 
    NotFound:
        End If
    Next ws
End Sub

A slight upgrade on the existing (which I found quite useful thank you) which will search all sheets.

Sub debug_print_array_formulas_all_sheets()
    Dim ws As Worksheet
    Dim rRange As Range, cell As Range
    Dim tot As Integer

    For Each ws In ThisWorkbook.Sheets
        On Error GoTo NotFound
        ws.Unprotect
        Dim v As Variant
        v = ws.UsedRange.HasFormula
        If IsNull(v) Or v Then

            Set rRange = ws.UsedRange.SpecialCells(xlCellTypeFormulas)
            tot = 0
            For Each cell In rRange
                If cell.HasArray Then
                    Debug.Print ws.Name & ":" & cell.Address & " " & cell.Formula
                    tot = tot + 1
                End If
             Next cell
             If tot > 0 Then
                Debug.Print "total number of array formula on " & ws.Name & ": " & tot
                tot = 0
             End If 
    NotFound:
        End If
    Next ws
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文