Macro to change all line weights of all series in all charts in one worksheet

mexaria

New Member
Joined
Apr 25, 2014
Messages
10
Hello Excel gurus,

I've a sheet with more than 50 graphs. I just want to change all series lines weight to 1.

I've written some code but (as usual) it did not work.

do you have any better idea or can you correct my code for it to work?

Thank you very much!
Kevin

Sub Change_all_charts()

Dim cht As Chart
Dim sht
Dim ChtObj As ChartObject
Dim srs As Series

For Each cht In ActiveWorkbook.Charts
cht.Activate
For Each srs In ActiveChart.SeriesCollection
srs.Format.Line.Weight = 1
Next
Next
End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Hi,

It never works when I do anything either!
You just have to tell it who is boss :)

Try this:
Code:
Sub Change_all_charts()

    Dim sht As Worksheet
    Dim ChtObj As ChartObject
    Dim srs As Series
    
    For Each sht In Worksheets
        For Each ChtObj In sht.ChartObjects
            For Each srs In ChtObj.Chart.SeriesCollection
                srs.Format.Line.Weight = 1
            Next
        Next
    Next
End Sub

Just a couple of subtle changes required.
 
Upvote 0
Hi,

It never works when I do anything either!
You just have to tell it who is boss :)

Try this:
Code:
Sub Change_all_charts()

    Dim sht As Worksheet
    Dim ChtObj As ChartObject
    Dim srs As Series
    
    For Each sht In Worksheets
        For Each ChtObj In sht.ChartObjects
            For Each srs In ChtObj.Chart.SeriesCollection
                srs.Format.Line.Weight = 1
            Next
        Next
    Next
End Sub

Just a couple of subtle changes required.

I found this when I was really DESPERATE to use one. And this works like a charm!!! Really wanna say thank you for the contributor! You saved me BIG time!

Regards,
DZ
 
Upvote 0
Anyway, just wondering if this could be done. I have 10 graph lines in one chart. Other than wanting to make it auto-change the weight as in the macro, is there any command lines (to be included in the same macro module above) that can format the marker for each graph line to be different as well? Like auto-assign by the excel itself?

Thank you in advance.

Best Regards,
DZ
 
Upvote 0

Forum statistics

Threads
1,215,415
Messages
6,124,764
Members
449,187
Latest member
hermansoa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top