Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

SAP Excel Makro: SAP Hierarchie Level auswerten

03.04.2019 (👁4769)


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