Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1204to1208
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Makro-Liste Anpassung

Makro-Liste Anpassung
Lutz
Hallo Excel Profis,
ich habe im Forum ein Makro gefunden, dass die Makros mit zugehörigem Modul auflistet:
Sub MakroListe()
Dim vbc As Object, iRow As Integer, iCol As Integer, iCounter As Integer, sMacro As String
Cells.Clear
Rows(1).Font.Bold = True
For Each vbc In ThisWorkbook.VBProject.VBComponents
iRow = 1
iCol = iCol + 1
Cells(iRow, iCol).Value = vbc.Name
Debug.Print vbc.Type
With vbc.CodeModule
For iCounter = 1 To .CountOfLines
If .ProcOfLine(iCounter, 0) > "" Then
sMacro = .ProcOfLine(iCounter, 0)
If sMacro  Cells(iRow, iCol) Then
iRow = iRow + 1
Cells(iRow, iCol).Value = sMacro
End If
End If
Next iCounter
End With
Next vbc
Columns.AutoFit
End Sub

Das ist auch gut aber es listet alles in Spalten auf - für jedes neue Modul eine neue Spalte
Ich wollte das jetzt so ändern, dass in Spalte A immer der Modulname steht und in Spalte B dann untereinander die Makros:
Sub MakroListe2()
Dim vbc As Object, iRow As Integer, iCol As Integer, iCounter As Integer, sMacro As String
Cells.Clear
Rows(1).Font.Bold = True
For Each vbc In ThisWorkbook.VBProject.VBComponents
iRow = iRow + 1
iCol = 1
Cells(iRow, iCol).Value = vbc.Name
Debug.Print vbc.Type
With vbc.CodeModule
For iCounter = 1 To .CountOfLines
If .ProcOfLine(iCounter, 0) > "" Then
sMacro = .ProcOfLine(iCounter, 0)
If sMacro  Cells(iRow, iCol) Then
iCol = iCol + 1
Cells(iRow, iCol).Value = sMacro
End If
End If
Next iCounter
End With
Next vbc
Columns.AutoFit
End Sub
Das klappt auch fast aber er listet dann die Makros in die Spalten B, C, D, E... je nachdem wie viele es gibt.
Was muß man noch ändern damit bei 3 Makros in einem Modul in den 3 Zeilen der Spalte A der Modulname und in den 3 Zeilen der Spalte B die Makronamen stehen?
Vielen Dank für Eure Hilfe.
Viele Grüße Lutz

1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: Makro-Liste Anpassung
24.03.2011 15:52:52
fcs
Hallo Lutz,
etwa so
Gruß
Franz
Sub MakroListe2()
Dim vbc As Object, iRow As Long, iCounter As Integer, sMacro As String
Dim sMacro_Previous As String, iRow1 As Long
Cells.Clear
Rows(1).Font.Bold = True
For Each vbc In ThisWorkbook.VBProject.VBComponents
sMacro_Previous = ""
iRow = iRow + 1
iRow1 = iRow '1. Zeile für Modul merken
Cells(iRow, 1).Value = vbc.Name
Debug.Print vbc.Type
With vbc.CodeModule
For iCounter = 1 To .CountOfLines
If .ProcOfLine(iCounter, 0) > "" Then
sMacro = .ProcOfLine(iCounter, 0)
If sMacro  sMacro_Previous Then
Cells(iRow, 1).Value = vbc.Name
Cells(iRow, 2).Value = sMacro
iRow = iRow + 1
sMacro_Previous = sMacro
End If
End If
Next iCounter
End With
If iRow1  iRow Then iRow = iRow - 1 'Wenn ein Modul Makros enthält Leerzeile vermeiden
Next vbc
Columns.AutoFit
End Sub

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige