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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,288
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,288
I am sorry, I assigned cChart the wrong type; just remove "As Chart" in the Dim instruction

Bye
 
Solution
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,488
Messages
5,770,384
Members
425,614
Latest member
rhobbo1

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