Move Graphs One Column To Right

J3lm3r

New Member
Joined
Mar 19, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello.

First post, please be kind :)

I have a sheet with several graphs. They are all stacked vertically. I´m looking for a macro that will send them all one column over to the right.
To select all charts I found:
VBA Code:
ActiveSheet.ChartObjects.Select
And based on a recorded macro, they can be moved to the right with:
Code:
IncrementLeft = 48
48 seems to be the increment level for 1 column.
I´m hoping there is a way to combine the two, and do what I need with the press of a button.

Thanks in advance!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
My suggestion:
VBA Code:
Sub ChartRePos()
Dim tlCel As String, cChart As Chart
'
tlCel = ActiveSheet.ChartObjects(1).TopLeftCell.Address
For Each cChart In ActiveSheet.ChartObjects
    cChart.Left = Range(tlCel).Offset(0, 1).Left
Next cChart
End Sub
This will check the position of graph #1, then will align all of them with the left border of the "next" column

Bye
 
Upvote 0
Hi Anthony,

This resulted in a Compile Error:

Capture.PNG


Any ideas to get around it?

Thank you!
 
Upvote 0
I am sorry, I assigned cChart the wrong type; just remove "As Chart" in the Dim instruction

Bye
 
Upvote 0
Solution

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

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