Solved

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

Posted on 2014-01-20
4
1,562 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
  • 2
  • 2
4 Comments
 
LVL 50

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 50

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Import Data from Multiple Text Files in Excel 12 58
Excel - INDEX MATCH error 13 23
get the ALL CAPITAL words from a cell 4 19
Getting rid of #VALUE! 7 19
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

809 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