• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Long Program....How Can I make this shorter

ianb

Member
Hi, I would like to shorten my program as I am doing this for over 100 charts...


IS there a way to do this for multi charts on multi worksheets.


Sheets("???????????Select

Range("A6").Select


ActiveSheet.ChartObjects("1").Activate

ActiveChart.ClearToMatchStyle

ActiveChart.ChartStyle = 18

ActiveChart.ClearToMatchStyle


ActiveSheet.ChartObjects("2").Activate

ActiveChart.ClearToMatchStyle

ActiveChart.ChartStyle = 18

ActiveChart.ClearToMatchStyle


ActiveSheet.ChartObjects("3").Activate

ActiveChart.ClearToMatchStyle

ActiveChart.ChartStyle = 18

ActiveChart.ClearToMatchStyle
 
You can use similar code to your other post:

[pre]
Code:
Sub Set_Chart_Titles()
Dim ws As Worksheet
Dim ch As ChartObject

For Each ws In Worksheets
For Each ch In ws.ChartObjects

ch.Activate
ActiveChart.ClearToMatchStyle
ActiveChart.ChartStyle = 18
ActiveChart.ClearToMatchStyle
Next ch
Next ws

End Sub
[/pre]
 
Perfect again. I think I wil try this as a templete for other settings as they look similar. many thanks again . save so much time working with the experts.
 
I'm not near my PC but the following may/should also work:

[pre]
Code:
Sub Set_Chart_Titles()
Dim ws As Worksheet
Dim ch As ChartObject

For Each ws In Worksheets
For Each ch In ws.ChartObjects
ch.ClearToMatchStyle
ch.ChartStyle = 18
ch.ClearToMatchStyle
Next ch
Next ws

End Sub
[/pre]
 
Back
Top