LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,489
Default VBA to specify chart location as obj in current sheet?

So do I Jon, if I know how and where the chart should be sized.

Cheers
Andy

Jon Peltier wrote:
I prefer

Dim chtob As ChartObject
Set chtob = ActiveSheet.ChartObjects.Add(Left, Top, Width, Height)
' where Left, etc., are coordinates in points
With chtob.Chart
' do your stuff here
End With

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Dr Dan" wrote in message
...

Thanks Andy, works great! :)

"Andy Pope" wrote:


Hi,

How about this,

Dim rngAC As Range

Set rngAC = ActiveCell
Columns("A:B").Select

With Charts.Add
.ChartType = xlXYScatterSmoothNoMarkers
With .Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With .Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
.Location Whe=xlLocationAsObject, Name:=rngAC.Parent.Name
End With

Cheers
Andy

Dr Dan wrote:

Hi,

I have recorded the following...

Sub Macro4()
'
' Macro4 Macro
' Macro recorded 23/02/2007 by Dan
'
' Keyboard Shortcut: Ctrl+f
'

Columns("A:B").Select
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveWindow.Visible = False
Windows("Master data.xls").Activate
End Sub

...this allows me to quickly plot a chart from the current sheet. How
do I
specify that I want the chart as an object within the current sheet?

I removed the line...

ActiveChart.Location Whe=xlLocationAsObject, Name:="20305A.TXT"

...after I recorded the macro as it only places each graph in the
original
worksheet, not the one I am working in. My book contains many sheets of
data.

Can anyone please advise how I can change the macro above to work so
that I
can go to any worksheet and run the macro, producing a plot of the data
on
that sheet as an object in that sheet.

Cheers,

Dan

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info





--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Indicate the location file on the work sheet Diane Excel Worksheet Functions 1 July 14th 06 05:00 PM
UDF is updateing cells on another sheet with count from current sheet. John Excel Discussion (Misc queries) 3 March 20th 06 03:58 PM
Track Mouse Location In a Sheet VBA mowali Excel Discussion (Misc queries) 0 June 13th 05 04:59 PM
location of chart bludik Charts and Charting in Excel 4 May 24th 05 12:24 PM
Can't save chart as object in current sheet Ann Scharpf Charts and Charting in Excel 1 December 3rd 04 11:24 PM


All times are GMT +1. The time now is 05:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"