LoginSignup
1
1

More than 3 years have passed since last update.

シートに定義されている関数を集める関数

Last updated at Posted at 2020-01-28

現在、開発を続けている旋盤管理システムのワークシートに埋め込まれている関数が複雑になりすぎ、整理するための一覧表が欲しくなったので、それ用の関数を作成しました。Insider限定です。

Function UFC_(Optional N = "発行01", Optional S = "")   ' UsedRange Function Collect

    Set WS = Worksheets(N)

    For Each A In WS.UsedRange
        F = A.Formula

        If Left(F, 1) = "=" And InStr(F, "(") > 0 Then
            B = A.Address(False, False)
            S = CC(S, B, F, "|")
        End If
    Next A
    S = Left(S, Len(S) - 1)
    S = Split(S, "|")
    With WorksheetFunction
        S = .Sort(.Transpose(S))
    End With
    UFC_ = S
End Function

Function CC(ParamArray AR())
    On Error Resume Next
    Dim S: S = ""
    Dim I: For I = 0 To UBound(AR)
       S = S & AR(I)
    Next I
    CC = S
End Function

使用する場合は、探索するワークシートとは別のワークシートに関数 UFC_ を定義して下さい。同じだと、循環でエラーになります。
出力結果は下記に。
image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1