ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I loop through workbook and rename all chart titles? (https://www.excelbanter.com/excel-programming/288974-how-do-i-loop-through-workbook-rename-all-chart-titles.html)

Backpaddler

How do I loop through workbook and rename all chart titles?
 
I have a workbook with about 45 worksheets, each of which have 2
charts. When the workbook is opened I get a 4 character code from th
user via an InputBox. I'd like to take this code and prefix ever
chart title in the workbook with it.

Could someone post an example of the VBA code that I'd use t
dynamically loop through every worksheet/chart and append this to th
existing chart titles?

Thanks a lot. I'm familiar with VB but not familiar enough with Exce
objects to get this done in time.

BackPaddle

--
Message posted from http://www.ExcelForum.com


pikus

How do I loop through workbook and rename all chart titles?
 
Here is the quick and dirty solution. I'm sure you can clean this up
bit, though. - Pikus

p = "PREF"
sheetCount = 45
For x = 1 To sheetCount
With Worksheets(x)
c = .ChartObjects.Count
For y = 1 To c
.ChartObjects(y).Chart.ChartTitle.Text = _
p & .ChartObjects(y).Chart.ChartTitle.Text
Next y
End With
Next

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com