Graphs Coming out of Alignment

dariushou

Board Regular
Joined
Feb 17, 2008
Messages
126
Hi,

I'm having a very frustrating time trying to keep graphs aligned and have been working on this one workbook for the past several weeks and just can't figure it out. Here is what i'm trying to do:

I have 4 graphs I want to align so they form a square with the borders touching each other...like a + sign. I can get them aligned like that, but once i run a Worksheet_change Macro the graphs come out of alignment. The Worksheet_Change Macro puts trendlines on the graphs but should not move anything. They are moving just slightly, but enough where it looks terrible (i'm eventually going to have about 20 graphs lined up so it'll look really unprofessional if they come out of alignment). I should add, that if i run any worksheet_Change then it will move these graphs (even if the worksheet_change does nothing to the graphs).

If you are familar with worksheet_change events, they make the screen flicker and right after that my graphs move. I'm talking milimeters here.

Please help. I can't find anything out there that will help and i've exhausted every resource I know.

--fyi: I've tried all 3 of the Object positioning options under the Size and Properties menu and the Snap to Grid. I have a macro that runs when the user clicks on the graph too so I'll need to be able to click the individual charts.

Thanks,
Darius
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Sorry for misunderstanding: graph is a chart? And you want them to be stacked? And write Excel version.
 
Upvote 0
Code:
Sub AlignChart()

    Dim shp As Shape
    
    Set shp = Sheets("Sheet1").Shapes("Chart1")
    
    With Range("A1:J20")
        shp.Top = .Top
        shp.Left = .Left
        shp.Height = .Height
        shp.Width = .Width
    End With

End Sub
 
Upvote 0
I apologize, it's Excel 2007. So i should include that in the change_event. I'll test and get back. Crossing my fingers.

Yes, a chart...line charts to be exact. Yes, i would like them to be stacked. Problem is some rows of charts will have 2 charts side by side and the next row of charts could have 2 or 3 charts side by side.
Thanks,
Darius
 
Last edited:
Upvote 0
Sektor,

Thanks for your help. I got that to work but a couple of questions. I'm new to VBA so bare with me. Is there a way to indicate which size (vertical and horizontal) instead of indicating a range? The reason being is that my columns have different widths and when you use ranges, two charts spanning over 4 different columns would have different sizes. I'm trying to keep all my charts the same size.

Also, how would I filter through all the charts on the page and line them up like in a grid. If each "-" sign below is a chart, my layout would look something like this:

--
---
---
--
---

Some rows of charts will have 3 charts and some 2 charts. Any ideas?

Thanks,
Darius
 
Upvote 0
Shape object has Width and Height properties. In my previous code shape was aligned with cells. You can use your own numbers. Play with them.
 
Upvote 0
I'm wondering if this is the right way. I'm not making the charts with VBA. The charts are already made. It's a worksheet_change macro that runs on the page that the charts are on that makes the charts go out of alignment due to the screen flickering. Isn't there some way to not make the charts move when an worksheet_change macro is run.

Thanks,
Darius
 
Upvote 0
Can anyone recommend anyone who does small scale excel work for a fee? I've spend 100s of hours on this task and it's driving me crazy. I'm throwing in the towl and gonna pay up.

Thanks,
Darius
 
Upvote 0
I would love to help you. However, 20 charts, are they all overlayed or just next to each other??

I typically make charts without using VBA or Macros.

What are your trying to accomplish?
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,348
Members
452,907
Latest member
Roland Deschain

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