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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,268
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
 

J3lm3r

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

This resulted in a Compile Error:

Capture.PNG


Any ideas to get around it?

Thank you!
 

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,268
I am sorry, I assigned cChart the wrong type; just remove "As Chart" in the Dim instruction

Bye
 
Solution

Forum statistics

Threads
1,147,517
Messages
5,741,629
Members
423,674
Latest member
Charles2dodo

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
Top