#1   Report Post  
CaliberX
 
Posts: n/a
Default Macro Charting

Me again.

I am trying to create a macro to create a chart as a new sheet. The
data I am charting is consistently in the same cells on multiple "data"
sheets. I am trying to create 1 chart per sheet.

I recorded a macro, and at this point:

Selection.Text = "='A-1 Data'!R4C5:R4C10"
ActiveChart.PlotArea.Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlNone

I would like to be able to automatically refer to the sheet that was
active when the macro was started. I would also like for the chart
sheet to be automatically named as per the chart title.

Can the macro also give me a user input with GUI where I can select the
xls file in which I would like the chart to be created?

Am I dreaming?

Thanks
CaliberX

  #2   Report Post  
Jon Peltier
 
Posts: n/a
Default

Start by declaring a worksheet variable

Dim wsChartData as Worksheet

Then define it as the activesheet when the macro starts, and refer to
the data range on this sheet.

Set wsChartData = ActiveSheet

Charts.Add
With ActiveChart
.SetSourceData wsChartData.Range("A1:E10"), xlByColumn
With .PlotArea.Border
.Weight = xlThin
.LineStyle = xlNone
End With
End With

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


CaliberX wrote:

Me again.

I am trying to create a macro to create a chart as a new sheet. The
data I am charting is consistently in the same cells on multiple "data"
sheets. I am trying to create 1 chart per sheet.

I recorded a macro, and at this point:

Selection.Text = "='A-1 Data'!R4C5:R4C10"
ActiveChart.PlotArea.Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlNone

I would like to be able to automatically refer to the sheet that was
active when the macro was started. I would also like for the chart
sheet to be automatically named as per the chart title.

Can the macro also give me a user input with GUI where I can select the
xls file in which I would like the chart to be created?

Am I dreaming?

Thanks
CaliberX

Reply
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
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 01:25 AM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Can't get simple macro to run Abi Excel Worksheet Functions 5 January 12th 05 07:37 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM


All times are GMT +1. The time now is 09:30 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"