graph mods using macros

JRS

New Member
Joined
Mar 10, 2011
Messages
44
Hi people,

could really use some urgent help if possible...

I have a macro that reads some data and creates a pivot table and chart onto the existing spreadsheet.

I now want to be able to specify where the chart is positioned (already sorted for the table). And also the dimensions of the chart.
I have tried creating the chart then recording a new macro while I manually move and resize the chart using the mouse, but the only code I get is "incremement xxx" and "Scale xxx" I was wondering if there is a more definitive way I can say the position and the size of the chart without it just remembering my previous mouse movements.


Any help would be greatly appreciated.
Many Thanks
JRS
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hi JRS

An example:

Your chart is called "MyChart", is in worksheet "Sheet1" and you want it to overlap the range J2:Q5.

Try:

Code:
Sub PositionChart()
Dim chtO As ChartObject
Dim r As Range
 
With Worksheets("Sheet1")
    Set chtO = .ChartObjects("MyChart")
    Set r = .Range("J2:Q15")
End With
 
With chtO
    .Left = r.Left
    .Top = r.Top
    .Width = r.Width
    .Height = r.Height
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,736
Members
452,940
Latest member
Lawrenceiow

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