SeniorNewbie
Board Regular
- Joined
- Jul 9, 2023
- Messages
- 77
- Office Version
- 2021
- 2019
- Platform
- Windows
- MacOS
Hi! out there,
with this little snippet I'm able to list all userdefined functions to a worksheet:
As you'll understand I'll get the name and the type of the procedure. What I need is the entire first line of the code e.g. Public Function KissMe(Sound as a String, Duration as Long, Taste as Byte)
I guess that it's only one line more in my code, but so far I'm helpless.
Thank you very much and have a nice weekend!
Newbie sr.
EDIT:
btw &fyi: Types are listed as:
100 = code in a sheet
1 = subs AND functions
3 = events in a userform
with this little snippet I'm able to list all userdefined functions to a worksheet:
VBA Code:
Option Explicit
Public Sub ListProcedures()
Dim oMod As Object
Dim i As Integer, iStart As Integer
Cells.Clear
i = 1
For Each oMod In ActiveWorkbook.VBProject.VBComponents
With oMod.CodeModule
If oMod.Name = "mdlFunctions" Then
iStart = .CountOfDeclarationLines + 1
Do Until iStart >= .CountOfLines
Cells(i, 1) = .ProcOfLine(iStart, 0)
Cells(i, 2) = oMod.Type & "*"
Cells(i, 3) = oMod.Name
iStart = iStart + .ProcCountLines(.ProcOfLine(iStart, 0), 0)
i = i + 1
Loop
End If
End With
Next
End Sub
I guess that it's only one line more in my code, but so far I'm helpless.
Thank you very much and have a nice weekend!
Newbie sr.
EDIT:
btw &fyi: Types are listed as:
100 = code in a sheet
1 = subs AND functions
3 = events in a userform
Last edited by a moderator: