Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default COPYING A CHART!

..Need help with 2 macros:

I have a chart occupying range("A1:AG30"). I need a macro that will
paste a copy of this first chart after every two rows till 50 copies of
the chart are made down the sheet.

Also, I need a blueprint for a second macro showing how to loop through
the charts and modify each chart's title and data source,etc if
possible.

Any help would be appreciated.

Thanks
Jay

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default COPYING A CHART!

Hi Jay:

Have a lookat the following sub.

It assumes you have one chart on the sheet and it sets the data area and
title
You need to modify the data areas and may be tweak some options.

Sub MakeCharts()
Const cszDataCSrt As String = "A" ' start column for data
Const cszDataCEnd As String = "B" ' end column for data
Const clNrDataRows As Long = 3 ' number of rows of data
Const clTitleOffsetRow As Long = -1 ' offset for title
Const clNrCharts As Long = 50 ' number of charts to make (ie less 1)
Const clRowOffset As Long = 10 ' increment for each chart
Dim iChart As Long ' chart count
Dim lRow As Long ' row pointer
Dim szData As String ' range for data
Dim szTitle As String ' range for title

lRow = 1 ' first row with the real chart in

For iChart = 2 To clNrCharts
' Copy chart
ActiveSheet.ChartObjects(1).Chart.ChartArea.Copy
' Set row and area to paste
lRow = lRow + clRowOffset
ActiveSheet.Range("D" & lRow).Select
ActiveSheet.Paste
' update the chart
With ActiveChart
' modify as needed
' data area
' source data modify
szData = cszDataCSrt & lRow & ":" & cszDataCEnd & lRow & _
"," & cszDataCSrt & lRow + 1 & ":" & cszDataCEnd & _
lRow + clNrDataRows
szTitle = cszDataCSrt & lRow + clTitleOffsetRow
.SetSourceData Source:=ActiveSheet.Range( _
szData), PlotBy:=xlColumns
' chart title
.HasTitle = True
.ChartTitle.Text = ActiveSheet.Range(szTitle)
End With
Next iChart
End Sub

--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"jay dean" wrote:

..Need help with 2 macros:

I have a chart occupying range("A1:AG30"). I need a macro that will
paste a copy of this first chart after every two rows till 50 copies of
the chart are made down the sheet.

Also, I need a blueprint for a second macro showing how to loop through
the charts and modify each chart's title and data source,etc if
possible.

Any help would be appreciated.

Thanks
Jay

*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default COPYING A CHART!

Hi Martin -

I will test and evaluate it and let you know. Thanks again.

Jay



*** Sent via Developersdex http://www.developersdex.com ***
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
copying a worksheet tab with a chart, without losing chart formatt davey888 Charts and Charting in Excel 0 September 5th 07 02:56 AM
copying excel chart formats from one chart to another [email protected] Excel Discussion (Misc queries) 0 August 31st 05 02:18 PM
copying a chart and/or bookmarking a chart me[_9_] Excel Programming 1 August 29th 05 01:45 AM
Copying Chart with Chart Series from Worksheet Name Joel Mills Excel Programming 2 June 25th 05 01:39 PM
Copying a chart Linda Mac Excel Programming 2 August 27th 04 06:02 PM


All times are GMT +1. The time now is 07:50 AM.

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"