I have a strange question and I hope someone can help me to figure it out.
I've a data set and want to have lines of various thickness that relates to a percentage of each value.
For example, I have different sources and want the line that represent line 1 with 65% to be the thickest and line 2 could be smaller and have 20% and line 3 the thinnest with the last 15%. Is there a way to have the line thickness auto adjust to represent the percentages?
11 Answer
It's possible to set the thickness of Line.
Option 1:
Line in Line graph only, using Cell values.
But always remember this procedure considers value as Numbers, in General format never as Percentage format.
To achieve the goal you need VBA (Macro).
How it Works:
- Enter required data in Sheet and assign NAME to the Range, using Formula then Define Name & finish with ok.
- Right click Sheet TAB & from Poped up Menu select View Code.
- Excel will open VB editor.
Copy & Paste this code as Standard Module.
Sub SetWidth() Dim Srs As Series Dim myWidth As Range Dim Rn As Range Dim j As Long Set myWidth = Range("Thickness") j = 1 With ActiveSheet For Each Rn In myWidth If j > ActiveChart.SeriesCollection.Count Then Exit Sub ActiveChart.SeriesCollection(j).Format.Line.Weight = Rn j = j + 1 Next Rn End With End SubSelect the Graph & RUN the Macro.
You find the new width to the Lines in the Graph.
Note, Thickness is the Name given to Range A1:C2, which is editable also.
Option 2:
Change the Height/Thickness of a Line object.
Use this Macro as Standard Module.
Sub LineWidth() With ActiveSheet.Shapes("Straight Connector 2") .Visible = True .Width = Range("A1").Value .Height = Range("A2").Value End With
End SubNote, Straight Connector 2 is Line object.