Doflamingo
Board Regular
- Joined
- Apr 16, 2019
- Messages
- 238
Hi all,
My goal is to automate a Structure/organizational chart with different elements included in a listbox (userform)
here is my current code on VBA of the command button which display on a excel sheet all the items of the listbox of my userform.
Dim i As Long
For i = 0 To ListBox1.ListCount - 1
Cells(5, i * 2+ 3) = ListBox1.List(i)
Cells(5, i * 2 + 3).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 144, 136.5, 216, 208.5). _
Select
Selection.ShapeRange.ShapeStyle = msoLineStylePreset15
Selection.ShapeRange.IncrementLeft -24
Selection.ShapeRange.IncrementTop -45
Selection.ShapeRange.ScaleWidth 0, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 1.25, msoFalse, msoScaleFromTopLeft
Next i
I've succeeded to put a connector to one of the item of the listbox, the next step and goal is to put connector to all of the different item of the listbox
any ideas ?
My goal is to automate a Structure/organizational chart with different elements included in a listbox (userform)
here is my current code on VBA of the command button which display on a excel sheet all the items of the listbox of my userform.
Dim i As Long
For i = 0 To ListBox1.ListCount - 1
Cells(5, i * 2+ 3) = ListBox1.List(i)
Cells(5, i * 2 + 3).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 144, 136.5, 216, 208.5). _
Select
Selection.ShapeRange.ShapeStyle = msoLineStylePreset15
Selection.ShapeRange.IncrementLeft -24
Selection.ShapeRange.IncrementTop -45
Selection.ShapeRange.ScaleWidth 0, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 1.25, msoFalse, msoScaleFromTopLeft
Next i
I've succeeded to put a connector to one of the item of the listbox, the next step and goal is to put connector to all of the different item of the listbox
any ideas ?