Solved

run macro on selected charts (resizing the chart area as well as data labels)

Posted on 2014-01-20
4
1,794 Views
Last Modified: 2014-01-23
Dear Experts:

for the selected charts on the active worksheet I would like to run the following VBA macro:

- Resize the charts to Width of 5 cm and Height of 9 cm
- Increase the size of the chart labels (all of them are pie charts) to 10 pt and font type 'Times New Roman'

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
Comment
Question by:AndreasHermle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 51

Expert Comment

by:Rgonzo1971
ID: 39794807
Hi,

pls try

Sub Makro7() '
' Makro7 Makro
For Each wks In Workbooks
    wks.Activate
    For Each cht In ActiveSheet.ChartObjects
        'cht.Legend.Format.TextFrame2.TextRange.Font.Size = 10
        cht.Chart.SeriesCollection(1).DataLabels.Format.TextFrame2.TextRange.Font.Size = 10
        cht.Chart.ChartArea.Height = Application.CentimetersToPoints(5)
        cht.Chart.ChartArea.Width = Application.CentimetersToPoints(9)
    Next
Next
End Sub

Open in new window

Regards
0
 

Author Comment

by:AndreasHermle
ID: 39797209
Hi Rgonzo,

thank you very much for your swift help. I will give your code a try soon, but as I can see all of the charts get worked on on the active worksheet.

I got charts on the active worksheet that should be left alone and only those charts that I selected by using the Shift-Key and clicking on them should be worked on. Is this possible, i.e. running the above macro just on selected charts ...

Regards, Andreas
0
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39797360
Hi,

pls try

Sub Makro7() '
' Makro7 Makro

For Each cht In Selection
    cht.Activate
    'cht.Legend.Format.TextFrame2.TextRange.Font.Size = 10
    cht.Chart.SeriesCollection(1).DataLabels.Format.TextFrame2.TextRange.Font.Size = 10
    cht.Chart.ChartArea.Height = Application.CentimetersToPoints(5)
    cht.Chart.ChartArea.Width = Application.CentimetersToPoints(9)
Next

End Sub

Open in new window

It is without test whether you select Charts or anything

Regards
0
 

Author Closing Comment

by:AndreasHermle
ID: 39804628
Great, this did the trick. Thank you very much for your professional help. Regards,  Andreas
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question