Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get Macro on one Worksheet to Work on Others

The following macro to makes a chart from Sheet foo in a workbook that has 20 Worksheets. Each worksheet is identical with regard to the data, hence the Range command always works.

Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("foo").Range("B3:B508,E3:E508"), _
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="foo"
ActiveChart.HasLegend = False

What needs to be done to make this work on all the worksheets in the Workbook.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Get Macro on one Worksheet to Work on Others

If the sheet to be worked on is the activesheet
Dim sName as String
Dim sh as Worksheet
sName = Activesheet.Name
set sh = activesheet
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=sh.Range("B3:B508,E3:E508"), _
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:=sName
ActiveChart.HasLegend = False

--
Regards

"Tom Dunlap" wrote in message
...
The following macro to makes a chart from Sheet foo in a workbook that has

20 Worksheets. Each worksheet is identical with regard to the data, hence
the Range command always works.

Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData

Source:=Sheets("foo").Range("B3:B508,E3:E508"), _
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="foo"
ActiveChart.HasLegend = False

What needs to be done to make this work on all the worksheets in the

Workbook.




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
Link one worksheet in a workbook to another worksheet in same work bjswise Excel Discussion (Misc queries) 1 February 6th 10 12:09 AM
Macro to update a column in a work based on another work sheet WickerMan New Users to Excel 1 December 4th 09 12:58 PM
Retrieving data into worksheet from another worksheet in same work Tasha Excel Discussion (Misc queries) 2 August 6th 09 03:51 PM
Copying the active worksheet to another worksheet in the same work queenmaam Excel Worksheet Functions 5 March 25th 08 06:56 PM
having a macro work only on a worksheet dennc01 Excel Programming 3 April 6th 04 11:05 PM


All times are GMT +1. The time now is 12:25 AM.

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

About Us

"It's about Microsoft Excel"