How to anchor charts to a cell location ? 
Author Message
 How to anchor charts to a cell location ?

Hi;

I have a macro which creates several charts and puts then on the excel
sheet in the midst of the data.  
    Note: FN is the filename of the result sheet.
    Charts.Add
    ActiveChart.ChartType = xlLine
    ActiveChart.SetSourceData Source:=Sheets(FN).Range(GraphRange),
PlotBy:=xlRows
    ActiveChart.Location Where:=xlLocationAsObject, Name:=FN

However, the initial location of the charts in the middle of the sheet
is influenced by the current view of the spreadsheet.  Moves ( ie:
ActiveSheet.Shapes(ChartName).IncrementLeft -165 ) are relative to the
location of the chart, not to the activecell.

Is there any way to insert a chart over a range of cells or at an
absolute location or to move the chart relative to the ActiveCell?

Thanks,

John Repucci



Mon, 10 Jul 2000 03:00:00 GMT  
 How to anchor charts to a cell location ?

Quote:

> Hi;

> I have a macro which creates several charts and puts then on the excel
> sheet in the midst of the data.
>     Note: FN is the filename of the result sheet.
>     Charts.Add
>     ActiveChart.ChartType = xlLine
>     ActiveChart.SetSourceData Source:=Sheets(FN).Range(GraphRange),
> PlotBy:=xlRows
>     ActiveChart.Location Where:=xlLocationAsObject, Name:=FN

> However, the initial location of the charts in the middle of the sheet
> is influenced by the current view of the spreadsheet.  Moves ( ie:
> ActiveSheet.Shapes(ChartName).IncrementLeft -165 ) are relative to the
> location of the chart, not to the activecell.

> Is there any way to insert a chart over a range of cells or at an
> absolute location or to move the chart relative to the ActiveCell?

> Thanks,

> John Repucci


Try this

Sub MoveChart()
    If ActiveCell.Column = 1 Then
        theleft = 0
    Else
        theleft = Range("A1", ActiveCell.Offset(0, -1)).Width
    End If
    If ActiveCell.Row = 1 Then
        thetop = 0
    Else
        thetop = Range("A1").Resize(ActiveCell.Row - 1).Height
    End If
    With ActiveSheet.ChartObjects(1)
        .Left = theleft
        .Top = thetop
    End With
End Sub



Tue, 11 Jul 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Anchoring objects and charts to cells during sorting

2. After first click on a cell, cursor anchors on that cell

3. Anchoring a sub-report location

4. anchoring tables to a fixed location in the page

5. Pie charts at marker locations on X-Y chart

6. !copying anchored-cell formulae

7. Formula Cell Anchor Reference

8. !copying anchored-cell formulae

9. anchored to cell - problem

10. Mouse anchors on a cell


 
Powered by phpBB® Forum Software © phpBB Group