Makro-Liste Anpassung
Lutz
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