excel - 组织架构亲子关系
问题描述
我正在为一家公司建立一个组织结构。但是,我当前的 VBA 脚本没有父子关系,例如(Team Leader 下的 Trainer)。如何在宏观中创建关系并将其显示在组织结构中?在下图中,Jodan 和 Sky 应该在 Jane 之下。VBA代码:
org()
org Macro
'Macro to generate organization chart
'
' Keyboard Shortcut: Ctrl+j
'
Dim ogSALayout As SmartArtLayout
Dim QNode As SmartArtNode
Dim QNodes As SmartArtNodes
Dim t As Integer
Set ogSALayout = Application.SmartArtLayouts(92) 'reference to organization chart
Set ogShp = ActiveWorkbook.ActiveSheet.Shapes.AddSmartArt(ogSALayout)
Set QNodes = ogShp.SmartArt.AllNodes
t = QNodes.Count
While QNodes.Count < t
QNodes(QNodes.Count).Delete
Wend
While QNodes.Count < Range("A1").End(xlDown).Row
QNodes.Add.Promote
Wend
For i = 1 To Range("A1").End(xlDown).Row
'Promote and demote nodes to put them at the proper level.
While QNodes(Range("A" & i)).Level < Range("C" & i).Value
QNodes(Range("A" & i)).Demote
Wend
'Copy the cell text to the node.
QNodes(Range("A" & i)).TextFrame2.TextRange.Text = Range("B" & i)
Next i
End Sub
解决方案
推荐阅读
- pandas - pd.read_csv 无法加载客户评论数据
- node.js - Socket.emit 带来多个值
- javascript - Angular JS 1.1:使用带有 ng-include 的共享 Angular 模块
- json - 从 for 循环插入文档时获取 XDMP-CONFLICTINGUPDATES
- jquery - jQuery更改格式不将格式更改为规定格式
- android - 使用来自 API 调用 Android 的数据显示 BottomSheet
- mobile - 使用 Bitrise 打开 STF 会导致无法获取设备序列号,错误:
- python - 列表中某个值范围内的最小值
- python - 如何获取对 discord.py 中的消息做出反应的成员列表?
- database - 使用带有 LiipFunctionalTestBundle 和 Postgresql 的夹具