Doflamingo
Board Regular
- Joined
- Apr 16, 2019
- Messages
- 238
Hi all,
Here is the code to create a structure chart from range A to range C of the sheet ‘’BD’’
Here is a screenshot of the sheet ‘’BD’’
https://www.dropbox.com/s/vyik32v24dp2ysm/sheet BD.png?dl=0
There is the ‘’Big father‘’ in A2 which is the ‘’Boss’’
The column B states all the ‘’sub father’’ with their ‘’children’’ that are in the column A except for the value ‘’Boss’’
For example the ‘’Boss’’ in cell A2 is the father of ‘’Vice President’’ in cell A3 that is the father of ‘’Employee13’’ in cell A11
The column C of the sheet ‘’BD’’ is the description of what you see inside the shapes in the sheet ‘’Shapes’’ where the structure chart is displayed once the macro is activated
Here is a screenshot of the sheet ‘’Shapes’’ of what I have currently with the data of the sheet ''BD''
https://www.dropbox.com/s/9p4pm5ukdmyly8h/Sheet Shapes.png?dl=0
Here is the code I have to display the structure chart in the sheet ''Shapes''
My problem is that I would like to expand my variables, I add a new range of variable in the column D of the sheet ‘’BD’’ and I would like that the specific variable be not included in the shapes like the variable of the column C are, but rather be below and at the left of the shapes they are related to.
Here a screenshot of what I would like to obtain
https://www.dropbox.com/s/emm9bkqm9eanmfm/goal.png?dl=0
I have changes the code above with the red lines that represent the values of the column D but that does not work
Any idea ?
Here is the code to create a structure chart from range A to range C of the sheet ‘’BD’’
Here is a screenshot of the sheet ‘’BD’’
https://www.dropbox.com/s/vyik32v24dp2ysm/sheet BD.png?dl=0
There is the ‘’Big father‘’ in A2 which is the ‘’Boss’’
The column B states all the ‘’sub father’’ with their ‘’children’’ that are in the column A except for the value ‘’Boss’’
For example the ‘’Boss’’ in cell A2 is the father of ‘’Vice President’’ in cell A3 that is the father of ‘’Employee13’’ in cell A11
The column C of the sheet ‘’BD’’ is the description of what you see inside the shapes in the sheet ‘’Shapes’’ where the structure chart is displayed once the macro is activated
Here is a screenshot of the sheet ‘’Shapes’’ of what I have currently with the data of the sheet ''BD''
https://www.dropbox.com/s/9p4pm5ukdmyly8h/Sheet Shapes.png?dl=0
Here is the code I have to display the structure chart in the sheet ''Shapes''
Code:
Sub créeShape(parent, niv, Attribut, coul) ' procédure récursive
hauteurshape = 48
largeurshape = 85
colonne = colonne + 1
forga.Shapes.AddShape(msoShapeFlowchartAlternateProcess, 10, 10, largeurshape, hauteurshape).Name = parent
forga.Shapes(parent).Line.ForeColor.SchemeColor = 1
txt = parent & vbLf & Attribut
With forga.Shapes(parent)
.TextFrame.Characters.Text = txt
.TextFrame.Characters(Start:=1, Length:=1000).Font.Size = 8
.TextFrame.Characters(Start:=1, Length:=1000).Font.ColorIndex = 0
.TextFrame.Characters(Start:=1, Length:=Len(parent)).Font.Bold = True
.TextFrame.Characters(Start:=1, Length:=Len(parent)).Font.ColorIndex = 3
.Fill.ForeColor.RGB = coul
End With
forga.Shapes(parent).Left = débutOrg.Left + inth * colonne
forga.Shapes(parent).Top = débutOrg.Top + intv * (niv - 1)
For i = 1 To n
If Tbl(i, 1) = parent And niv > 1 Then
shapePère = Tbl(i, 2)
forga.Shapes.AddConnector(msoConnectorElbow, 100, 100, 100, 100).Name = parent & "c"
forga.Shapes(parent & "c").Line.ForeColor.SchemeColor = 22
forga.Shapes(parent & "c").ConnectorFormat.BeginConnect forga.Shapes(shapePère), 3
forga.Shapes(parent & "c").ConnectorFormat.EndConnect forga.Shapes(parent), 1
End If
If Tbl(i, 2) = parent Then créeShape Tbl(i, 1), niv + 1, Tbl(i, 3), f.Cells(i + 1, 1).Interior.Color
Next i
End Sub
Here a screenshot of what I would like to obtain
https://www.dropbox.com/s/emm9bkqm9eanmfm/goal.png?dl=0
I have changes the code above with the red lines that represent the values of the column D but that does not work
Code:
Sub créeShape(parent, niv, Attribut, coul) ' procédure récursive
hauteurshape = 48
largeurshape = 85
colonne = colonne + 1
forga.Shapes.AddShape(msoShapeFlowchartAlternateProcess, 10, 10, largeurshape, hauteurshape).Name = parent
forga.Shapes(parent).Line.ForeColor.SchemeColor = 1
txt = parent & vbLf & Attribut
With forga.Shapes(parent)
.TextFrame.Characters.Text = txt
.TextFrame.Characters(Start:=1, Length:=1000).Font.Size = 8
.TextFrame.Characters(Start:=1, Length:=1000).Font.ColorIndex = 0
.TextFrame.Characters(Start:=1, Length:=Len(parent)).Font.Bold = True
.TextFrame.Characters(Start:=1, Length:=Len(parent)).Font.ColorIndex = 3
.Fill.ForeColor.RGB = coul
End With
forga.Shapes(parent).Left = débutOrg.Left + inth * colonne
forga.Shapes(parent).Top = débutOrg.Top + intv * (niv - 1)
For i = 1 To n
If Tbl(i, 1) = parent And niv > 1 Then
shapePère = Tbl(i, 2)
forga.Shapes.AddConnector(msoConnectorElbow, 100, 100, 100, 100).Name = parent & "c"
forga.Shapes(parent & "c").Line.ForeColor.SchemeColor = 22
forga.Shapes(parent & "c").ConnectorFormat.BeginConnect forga.Shapes(shapePère), 3
forga.Shapes(parent & "c").ConnectorFormat.EndConnect forga.Shapes(parent), 1
End If
If Tbl(i, 2) = parent Then créeShape Tbl(i, 1), niv + 1, Tbl(i, 3), f.Cells(i + 1, 1).Interior.Color
Next i
[COLOR=#ff0000] For u = 1 To n[/COLOR]
[COLOR=#ff0000] If Tbl(u, 1) = parent And niv > 1 Then[/COLOR]
[COLOR=#ff0000] shapePère = Tbl(u, 2)[/COLOR]
[COLOR=#ff0000] [/COLOR]
[COLOR=#ff0000] forga.Shapes.AddConnector(msoConnectorElbow, 100, 100, 100, 100).Name = parent & "d"[/COLOR]
[COLOR=#ff0000] [/COLOR]
[COLOR=#ff0000] forga.Shapes(parent & "d").Line.ForeColor.SchemeColor = 22[/COLOR]
[COLOR=#ff0000] forga.Shapes(parent & "d").ConnectorFormat.BeginConnect forga.Shapes(shapePère), 3[/COLOR]
[COLOR=#ff0000] forga.Shapes(parent & "d").ConnectorFormat.EndConnect forga.Shapes(parent), 1[/COLOR]
[COLOR=#ff0000] [/COLOR]
[COLOR=#ff0000] End If[/COLOR]
[COLOR=#ff0000] [/COLOR]
[COLOR=#ff0000] If Tbl(u, 2) = parent Then créeShape Tbl(u, 1), niv + 1, Tbl(u, 3), f.Cells(u + 1, 1).Interior.Color[/COLOR]
[COLOR=#ff0000] Next u[/COLOR]
End Sub
Any idea ?