' ser$ = "=SERIES(" & Chr$(34) & CN$ & Chr$(34) & ",'" & ActiveWorkbook.Name & "'!" & CN$ & "_xs,'" & ActiveWorkbook.Name & "'!" & CN$ & "_ys,1)"
' ActiveChart.SeriesCollection(1).Formula = ser$
'ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).Name = "=" & Chr$(34) & CN$ & Chr$(34)
ActiveChart.SeriesCollection(1).XValues = "='" & ActiveWorkbook.Name & "'!" & CN$ & "_xs"
ActiveChart.SeriesCollection(1).Values = "='" & ActiveWorkbook.Name & "'!" & CN$ & "_ys"
With ActiveChart.SeriesCollection(1)
.Border.Line = xlNone
.MarkerBackgroundColor = RGB(0, 0, 200)
.MarkerForegroundColor = RGB(0, 0, 212)
.Marker = xlCircle
.Smooth = False
.MarkerSize = 7
.Shadow = False
If trcap = 1 Then .MarkerTransparency = 0.25
'.Formula = ser$
End With
' add data labels if required
If dlb = 1 Then
For p = 1 To ActiveChart.SeriesCollection(1).Points.Count
' dynamic label text
lbt$ = "='" & ActiveSheet.Name & "'!" & sel.Cells(p, 1).Address(, , xlR1C1) ' sel.Cells(p, 1).Value
With ActiveChart.SeriesCollection(1).Points(p)
.HasDataLabel = True
.DataLabel.Text = lbt$ ' "=" & sel.Cells(p, 1).Address
.DataLabel.Font.Name = "Arial Narrow"
.DataLabel.Font.Size = 10
'.DataLabel.Font.Italic = True
End With
Next p
End If
' define cartesian cage ("1st Octant")
ActiveWorkbook.Names.Add Name:="cagex", RefersTo:="={0.5,-0.5,-0.5,0.5,0.5,0.5,-0.5,-0.5,-0.5,-0.5,-0.5}"
ActiveWorkbook.Names.Add Name:="cagey", RefersTo:="={-0.5,-0.5,-0.5,-0.5,-0.5,0.5,0.5,0.5,-0.5,-0.5,0.5}"
ActiveWorkbook.Names.Add Name:="cagez", RefersTo:="={-0.5,-0.5,0.5,0.5,-0.5,-0.5,-0.5,0.5,0.5,-0.5,-0.5}"
'={1\0\0\1\1\1\0\0\0\0\0} 'names dialog box will display backward-slashes \ as delimiter, but only commas, work in VBA code. Weird that
'={0\0\0\0\0\1\1\1\0\0\1}
'={0\0\1\1\0\0\0\1\1\0\0}
' calculate screen coordinates for cartesian cage
ActiveWorkbook.Names.Add Name:=CN$ & "_xs_cage", RefersTo:="=" & "cagex *" & CN$ & "_rx1+" & "cagey *" & CN$ & "_ry1+" & "cagez *" & CN$ & "_rz1"
ActiveWorkbook.Names.Add Name:=CN$ & "_ys_cage", RefersTo:="=" & "cagex *" & CN$ & "_rx2+" & "cagey *" & CN$ & "_ry2+" & "cagez *" & CN$ & "_rz2"
ActiveChart.SeriesCollection.NewSeries
ns = ActiveChart.SeriesCollection.Count
ActiveChart.SeriesCollection(ns).Name = "=" & Chr$(34) & "cage" & Chr$(34)
ActiveChart.SeriesCollection(ns).XValues = "='" & ActiveWorkbook.Name & "'!" & CN$ & "_xs_cage"
ActiveChart.SeriesCollection(ns).Values = "='" & ActiveWorkbook.Name & "'!" & CN$ & "_ys_cage"
With ActiveChart.SeriesCollection(ns)
.Border.Color = RGB(150, 150, 150)
.Border.LineWeight = 0
.Border.Line = xlContinuous
If trcap = 1 Then .Border.Transparency = 0.5
.Marker = xlNone
.Smooth = False
.Shadow = False
End With
ns = ActiveChart.SeriesCollection.Count
' add data labels to cage to mark positive x axis direction
If sel.Cells(1, 1 + dlb).Offset(-1, 0).Value = "" Then sel.Cells(1, 1 + dlb).Offset(-1, 0).Value = "X axis"
lbt$ = "='" & ActiveSheet.Name & "'!" & sel.Cells(1, 1 + dlb).Offset(-1, 0).Address(, , xlR1C1)
With ActiveChart.SeriesCollection(ns).Points(1)
.HasDataLabel = True
.DataLabel.Text = lbt$
.DataLabel.Font.Name = "Arial Narrow"
.DataLabel.Font.Size = 12
.DataLabel.Position = xlLabelPositionLeft
'.DataLabel.Font.Italic = True
End With
' add data labels to cage to mark positive y axis direction
If sel.Cells(1, 2 + dlb).Offset(-1, 0).Value = "" Then sel.Cells(1, 2 + dlb).Offset(-1, 0).Value = "Y axis"
lbt$ = "='" & ActiveSheet.Name & "'!" & sel.Cells(1, 2 + dlb).Offset(-1, 0).Address(, , xlR1C1)
With ActiveChart.SeriesCollection(ns).Points(11)
.HasDataLabel = True
.DataLabel.Text = lbt$
.DataLabel.Font.Name = "Arial Narrow"
.DataLabel.Font.Size = 12
.DataLabel.Position = xlLabelPositionRight
'.DataLabel.Font.Italic = True
End With
' add data labels to cage to mark positive z axis direction
If sel.Cells(1, 3 + dlb).Offset(-1, 0).Value = "" Then sel.Cells(1, 3 + dlb).Offset(-1, 0).Value = "Z axis"
lbt$ = "='" & ActiveSheet.Name & "'!" & sel.Cells(1, 3 + dlb).Offset(-1, 0).Address(, , xlR1C1)
With ActiveChart.SeriesCollection(ns).Points(9)
.HasDataLabel = True
.DataLabel.Text = lbt$
.DataLabel.Font.Name = "Arial Narrow"
.DataLabel.Font.Size = 12
.DataLabel.Position = xlLabelPositionAbove
'.DataLabel.Font.Italic = True
End With
' define position of cut planes (from slider positions)
ActiveWorkbook.Names.Add Name:=CN$ & "_cpx", RefersTo:="=" & CN$ & "_CP1/100 - 0.5"
ActiveWorkbook.Names.Add Name:=CN$ & "_cpy", RefersTo:="=" & CN$ & "_CP2/100 - 0.5"
ActiveWorkbook.Names.Add Name:=CN$ & "_cpz", RefersTo:="=" & CN$ & "_CP3/100 - 0.5"
' default geometry for cut plane outlines
ActiveWorkbook.Names.Add Name:="plane1", RefersTo:="={-0.5,0.5,0.5,-0.5,-0.5}"
ActiveWorkbook.Names.Add Name:="plane2", RefersTo:="={-0.5,-0.5,0.5,0.5,-0.5}"
'plane1 ={0\1\1\0\0}
'plane2 ={0\0\1\1\0}
' calculate screen coordinates for datapoints of three cut planes
ActiveWorkbook.Names.Add Name:=CN$ & "_xs_cpx", RefersTo:="=" & CN$ & "_cpx *" & CN$ & "_rx1+" & CN$ & "_normy *" & CN$ & "_ry1+" & CN$ & "_normz *" & CN$ & "_rz1"
ActiveWorkbook.Names.Add Name:=CN$ & "_ys_cpx", RefersTo:="=" & CN$ & "_cpx *" & CN$ & "_rx2+" & CN$ & "_normy *" & CN$ & "_ry2+" & CN$ & "_normz *" & CN$ & "_rz2"
ActiveWorkbook.Names.Add Name:=CN$ & "_xs_cpy", RefersTo:="=" & CN$ & "_normx *" & CN$ & "_rx1+" & CN$ & "_cpy *" & CN$ & "_ry1+" & CN$ & "_normz *" & CN$ & "_rz1"
ActiveWorkbook.Names.Add Name:=CN$ & "_ys_cpy", RefersTo:="=" & CN$ & "_normx *" & CN$ & "_rx2+" & CN$ & "_cpy *" & CN$ & "_ry2+" & CN$ & "_normz *" & CN$ & "_rz2"
ActiveWorkbook.Names.Add Name:=CN$ & "_xs_cpz", RefersTo:="=" & CN$ & "_normx *" & CN$ & "_rx1+" & CN$ & "_normy *" & CN$ & "_ry1+" & CN$ & "_cpz *" & CN$ & "_rz1"
ActiveWorkbook.Names.Add Name:=CN$ & "_ys_cpz", RefersTo:="=" & CN$ & "_normx *" & CN$ & "_rx2+" & CN$ & "_normy *" & CN$ & "_ry2+" & CN$ & "_cpz *" & CN$ & "_rz2"
' calculate screen coordinates for outlines of three cut planes
ActiveWorkbook.Names.Add Name:=CN$ & "_xs_planex", RefersTo:="=" & CN$ & "_cpx *" & CN$ & "_rx1+" & "plane1 *" & CN$ & "_ry1+" & "plane2 *" & CN$ & "_rz1"
ActiveWorkbook.Names.Add Name:=CN$ & "_ys_planex", RefersTo:="=" & CN$ & "_cpx *" & CN$ & "_rx2+" & "plane1 *" & CN$ & "_ry2+" & "plane2 *" & CN$ & "_rz2"
ActiveWorkbook.Names.Add Name:=CN$ & "_xs_planey", RefersTo:="=" & "plane1 *" & CN$ & "_rx1+" & CN$ & "_cpy *" & CN$ & "_ry1+" & "plane2 *" & CN$ & "_rz1"
ActiveWorkbook.Names.Add Name:=CN$ & "_ys_planey", RefersTo:="=" & "plane1 *" & CN$ & "_rx2+" & CN$ & "_cpy *" & CN$ & "_ry2+" & "plane2 *" & CN$ & "_rz2"
ActiveWorkbook.Names.Add Name:=CN$ & "_xs_planez", RefersTo:="=" & "plane1 *" & CN$ & "_rx1+" & "plane2 *" & CN$ & "_ry1+" & CN$ & "_cpz *" & CN$ & "_rz1"
ActiveWorkbook.Names.Add Name:=CN$ & "_ys_planez", RefersTo:="=" & "plane1 *" & CN$ & "_rx2+" & "plane2 *" & CN$ & "_ry2+" & CN$ & "_cpz *" & CN$ & "_rz2" |