Name
chart
.Location(Where
, [Name
])
Synopsis
Moves the chart to a new worksheet or chart sheet.
Argument |
Settings |
---|---|
|
An |
|
The name of the target worksheet or chart sheet. |
The Location
method removes the chart from its current location and inserts it in the new location. For example, the first procedure in the following code block removes the chart sheet New Chart
and inserts the chart as an embedded object on the Start
worksheet; the second procedure moves the embedded chart back to a chart sheet:
Sub MoveChartToStart( ) Dim chrt As Chart Set chrt = Charts("New Chart") chrt.Location xlLocationAsObject, "Start" End Sub Sub MoveChartBack( ) Dim chrt As Chart Set chrt = Worksheets("Start").ChartObjects(1).Chart chrt.Location xlLocationAsNewSheet ActiveSheet.Name = "New Chart" End Sub
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.