Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to edit the weight of all lines at once on an Excel line chart?

I have a graph with about 50 data series on it, and it's too much to go through all of them and change the weights individually, and it's hard to see the data if the lines were thinner, it'd be a bit easier). I can't see a way to multi-select them, which seems a bit awful.

Edit: I eventually got it working with the following code (after learning a bit of VB). I doesn't seem to help readability of the graph much though! Chris helped me sort it out, so I'll give him the tick.

Sub onepxlines()
        With Selection
            MsgBox ("Selection: " & TypeName(Selection))
            If TypeName(Selection) = "ChartArea" Then
                Dim area As ChartArea
                Set area = Selection

                MsgBox ("Area parent: " & TypeName(area.Parent))

                If TypeName(area.Parent) = "Chart" Then
                    Dim chart As chart
                    Set chart = area.Parent
                    Dim srs As Series

                    For Each srs In chart.SeriesCollection
                        srs.Format.Line.Weight = 1.5
                    Next
                End If
            End If
        End With
End Sub
share|improve this question

4 Answers 4

up vote 2 down vote accepted

Probably easiest to write a quick macro, somthing like

Sub SetWeights()
    Dim srs As Series
    For Each srs In ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection
        srs.Format.Line.Weight = 0.75
    Next
End Sub
share|improve this answer
    
Cheers, I'll try this out :) –  Chris Dennett Nov 16 '11 at 14:51

This worked perfectly for me. I used this code to have it edit all lines in all charts on all sheets of a workbook

Sub ChangeLineType()

'This macro will print all embedded charts in the active workbook
'
    Application.ScreenUpdating = False
    Dim Sht As Object
    Dim Cht As ChartObject
    For Each Sht In ActiveWorkbook.Sheets
        For Each Cht In Sht.ChartObjects
            Cht.Activate
            ActiveChart.ChartArea.Select
            'ActiveWindow.SelectedSheets.PrintOut
                Dim srs As Series
                For Each srs In ActiveChart.SeriesCollection
                srs.Format.Line.Weight = 0.25
                Next
        Next
    Next
End Sub
share|improve this answer

I don't think you can multi-select lines. The simplest way is probably to change one and then to select each on in turn use Ctrl-Y to go through and re-do the line weight change.

share|improve this answer
    
There's got to be something better than this. Maybe something like a custom chart style? –  Chris Dennett Nov 16 '11 at 1:54

This is a more copy-and-paste compatible version of Chris's answer:

Sub SetWeights()
    Dim srs As Series
    For Each srs In ActiveChart.SeriesCollection
        srs.Format.Line.Weight = 0.25
    Next
End Sub

Just select the chart and run the macro.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.