#

SAP Excel Makro: Hierarchie Level auswerten
 
Mit dem folgenden Excel vba Makro kann man die SAP Levels einer Hierarchie Spalte auswerten

 

Option Explicit
 
Public Sub BtnCheck_SAP_Level()
Check_SAP_Level
End Sub
 
 
 
Public Sub Check_SAP_Level()
'-------------< Check_SAP_Level() >-----------------
'< init >
Dim wb As Workbook
Set wb = ActiveWorkbook
Dim ws As Worksheet
Set ws = ActiveSheet
'</ init >
 
Dim used_Range As Range
Set used_Range = ws.usedRange


'--------< @Loop: Rows >---------
Dim used_row As Range
For Each used_row In used_Range.Rows
'--------< row >-------
Dim cell As Range
Set cell = ws.Range("C" & used_row.row)
Dim sFormat As String
sFormat = cell.NumberFormat
If InStr(sFormat, "]") > 0 Then
'SAP Hierarchie Format wie: "" [-] "@"
Dim sSapFormat As String
sSapFormat = Mid(sFormat, 1, InStr(sFormat, "[") - 1) '"" [-]"
Dim sapLevel As Integer
sapLevel = Len(sSapFormat)

'< Ausgabe >
ws.Range("B" & used_row.row).Value = sapLevel
'</ Ausgabe >
End If
'--------</ row >-------
Next
'--------</ @Loop: Rows >---------

MsgBox "Fertig"
'-------------</ Check_SAP_Level() >-----------------
End Sub

 
 
 
 
 
Mobile

.

0123movie.net