Moving Charts

  • Thread starter Thread starter Ken
  • Start date Start date
K

Ken

I have a set of macros that loop through all my worksheets and move my charts.

I have found that the charts do not always move. Do I need to place some
type refresh after each move?

Thank you.
 
Moving charts should be pretty straightforward with no need to 'Refresh'.
More likely your code is not doing what you think it is.

Regards,
Peter T
 
Hi Peter,

Here is the code I am using:

Set objChart = oSheet.ChartObjects(PlotName)

objChart.Activate

With objChart
.Top = PlotTop
.Left = PlotLeft
.Width = PlotWidth
.Height = PlotHeight
End With

I calculate PlotTop using:

PlotTop = oSheet.Rows(ChartTopRow).Top

oSheet is set to the current worksheet (worksheet object) and ChartTopRow is
set to 44. The plot is moving to the top of row 57.

Ken
 
From what you've described your code looks OK but we can't see your actual
variables, so must be something else only you can see. Eg, what's
ChartTopRow

Sub test()
Dim lt As Double
Dim tp As Double
Dim chtObj As ChartObject

lt = ActiveSheet.Columns(2).Left
tp = ActiveSheet.Rows(44).Top

Set chtObj = ActiveSheet.ChartObjects.Add(0, 0, 200, 100)

With chtObj
.Left = lt
.Top = tp
End With
Application.Goto Range("a40"), True

End Sub

In passing, no need to Activate your chart

Regards,
Peter T
 
Peter,

ChartTopRow was a variable I passed into a move and position funciton. I
found the problem in that I was passing in the ChartTopRow byref and it
should have been byval as I was modifying it in the code.

Thanks for the help.
 
Back
Top