当前位置:网站首页>人力资源导出数据 excel VBA

人力资源导出数据 excel VBA

2022-06-26 14:46:00 gavingxh

切换HR系统,从sap导出来(用 RH_STRUC_GET)的 数据整理后是这样的 

01O10000000杰克1#N/A
12O10000006董事会210000000杰克
27O50007060集团副总裁310000006董事会
745S50007057集团副总裁450007060集团副总裁
45234P18000550007057集团副总裁
28S20000008创始人310000006董事会
846P1420000008创始人
29S20000009副董事长310000006董事会
947P2420000009副董事长
948P3420000009副董事长
210S20000010董事长310000006董事会
1049P66420000010董事长
211S20000011独立董事310000006董事会
1150P42420000011独立董事
1151P40000784420000011独立董事
1152P40000785420000011独立董事
1153P40000786420000011独立董事
13O50006566杰克股份210000000杰克
312O50006692营销管理部350006566杰克股份
1254O50019311副总办450006692营销管理部
54235S50006843营销副总经理550019311副总办
235789P15650006843营销副总经理
235790P1219650006843营销副总经理
235791P4331650006843营销副总经理
1255O50006851秘书450006692营销管理部
55236S50006850秘书550006851秘书
236792P10324650006850秘书

目标 

想做成

 

导出来的组织通过有上下级关系,通过vlookup 引过来 名称 ,

为帮助人力完成结果 写了一小段VBA

Sub runva01()
Dim i, j, itemi, itemj, strp, modvalue, orgstr, ordidstr, pup, pseqindx
itemi = 2
itemj = 10998
 
For i = itemi To itemj
modvalue = Cells(i, 3)
orgstr = ""
ordidstr = ""
If modvalue = "S" Then
    Cells(i, 12) = Cells(i, 4)
    Cells(i, 11) = Cells(i, 5)
    
    pup = Cells(i, 1)
     For j = 2 To i
        If Cells(j, 2) = pup Then
          If Cells(j, 3) = "O" Then
            pseqindx = j
           End If
        End If
        Next
      While pup <> 0
        orgstr = Cells(pseqindx, 5) & "/" & orgstr
        ordidstr = Cells(pseqindx, 4) & "/" & ordidstr
        For j = 2 To i
        If Cells(j, 2) = pup Then
          If Cells(j, 3) = "O" Then
            pseqindx = j
           End If
        End If
        Next
        pup = Cells(pseqindx, 1)
         For j = 2 To i
        If Cells(j, 2) = pup Then
          If Cells(j, 3) = "O" Then
            pseqindx = j
           End If
        End If
Next
    Wend
    Cells(i, 9) = orgstr
    Cells(i, 10) = ordidstr
End If

Next
End Sub

原网站

版权声明
本文为[gavingxh]所创,转载请带上原文链接,感谢
https://blog.csdn.net/xiaofei2008gxh/article/details/125455584