Forum Statistics
- Forum Members:
- Total Threads:
- Total Posts: 9
There are 1 users currently browsing forums.
|
 |

06-28-2009, 08:34 PM
|
|
Registered User
|
|
Join Date: 28 Jun 2009
Location: boston, ma
MS Office Version:Excel 2003
Posts: 1
|
|
|
Apply default chart to multiple worksheets?
Please Register to Remove these Ads
Hi,
I have a chart format that I want to apply to same data format through 100's separate worksheets in one work.
1. Apply custom chart template
2. Change column titles from series 1,2,3,4 to may, apr, mar, feb, oct
3. Change chart titles to coo function for y axis and time for x axis
I have done this already by recording separate marcos but applying it to 100's of worksheets does not work.
Can anyone help?
Best,
Frank
|

07-03-2009, 04:15 AM
|
|
Forum Contributor
|
|
Join Date: 03 Apr 2007
Location: Auckland, New Zealand
MS Office Version:2007
Posts: 121
|
|
|
Re: Apply default chart to multiple worksheets?
Hi,
Are you able to post an example of say 3 sheets and the code you've recorded as an attached file.
Always easier to work with examples
|

07-17-2009, 12:37 PM
|
|
Registered User
|
|
Join Date: 06 Feb 2005
Posts: 16
|
|
|
Re: Apply default chart to multiple worksheets?
Hi,
Sorry for the delay but here is an example of what i am trying to do. I want to apply this chart template to the data in the worksheets.
|

07-18-2009, 06:30 AM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,207
|
|
|
Re: Apply default chart to multiple worksheets?
Should your chart not be a xy-scatter rather than a Line chart type?
|

07-18-2009, 09:56 PM
|
|
Registered User
|
|
Join Date: 06 Feb 2005
Posts: 16
|
|
|
Re: Apply default chart to multiple worksheets?
This is the correct file format for this type of dataset :-)
|

07-19-2009, 07:16 AM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,207
|
|
|
Re: Apply default chart to multiple worksheets?
Here is a routine to duplicate the chart across the sheets.
It should also work with other workbooks, taking the existing chart from the Title sheet and copying it across.
I realise it's your data and your chart but just check the difference in the plots by comparing the copied chart to the existing one on sheet2.
The xy-scatter has true value axis rather than category one that the line provides. I'm sure you would agree that the outcome of the lines is radically different.
|

07-19-2009, 01:26 PM
|
|
Registered User
|
|
Join Date: 06 Feb 2005
Posts: 16
|
|
|
Re: Apply default chart to multiple worksheets?
Hi,
Thank you for the input and the x domain is not linear time but it is a sampling time (i can explain application offline).
The time domain x will be the sample for all the measurements. We will then have different number of replicates. It could be anywhere from 3-15 replicates.
We would like to average the number of replicates, obtain standard deviation, % relative std deviation and plot the chart to the right side of the data.
Here is a file of what we are trying to do with a macro i recorded. If we could automate the data processing side and add the chart component that your provided. We would dramatically reduce our data processing time and help us do some real science :-)
Frank
|

07-20-2009, 06:36 AM
|
 |
Forum Guru
|
|
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,207
|
|
|
Re: Apply default chart to multiple worksheets?
Try this code modification for adding 3 calculated columns.
Code:
Sub X()
Dim chtTemplate As Chart
Dim shtTemp As Worksheet
Dim lngLastRow As Long
Dim chtLocal As Chart
Dim lngCol As Long
Dim lngSeries As Long
Dim objSeries As Series
Set chtTemplate = ThisWorkbook.Worksheets("Title").ChartObjects(1).Chart
Application.ScreenUpdating = False
For Each shtTemp In ActiveWorkbook.Worksheets
If shtTemp.Name <> chtTemplate.Parent.Parent.Name Then
If shtTemp.Cells(4, 1) <> "" Then
lngLastRow = shtTemp.Cells(shtTemp.Rows.Count, 1).End(xlUp).Row
With chtTemplate.Parent
.Copy
shtTemp.Paste
Set chtLocal = shtTemp.ChartObjects(shtTemp.ChartObjects.Count).Chart
With chtTemplate.Parent
chtLocal.Parent.Left = .Left
chtLocal.Parent.Top = .Top
chtLocal.Parent.Width = .Width
chtLocal.Parent.Height = .Height
End With
End With
lngCol = 2
Do While shtTemp.Cells(4, lngCol) <> ""
If lngCol - 1 <= chtTemplate.SeriesCollection.Count Then
' Use existing series
Set objSeries = chtLocal.SeriesCollection(lngCol - 1)
Else
Set objSeries = chtLocal.SeriesCollection.NewSeries
End If
With objSeries
' update range reference
.Name = shtTemp.Cells(4, lngCol)
.Values = shtTemp.Range(shtTemp.Cells(5, lngCol), shtTemp.Cells(lngLastRow, lngCol))
End With
lngCol = lngCol + 1
Loop
With shtTemp
.Cells(4, lngCol).Resize(1, 3) = Array("Average", "Standard Deviation", "% RSD")
'Average
shtTemp.Cells(5, lngCol).Formula = "=AVERAGE(B5:" & .Cells(5, lngCol - 1).Address(False, False) & ")"
' STDEV
shtTemp.Cells(5, lngCol + 1).Formula = "=STDEV(B5:" & .Cells(5, lngCol - 1).Address(False, False) & ")"
' %RSD
shtTemp.Cells(5, lngCol + 2).Formula = "=(" & _
.Cells(5, lngCol + 1).Address(False, False) & "/" & _
.Cells(5, lngCol).Address(False, False) & ")*100"
' Populate all rows
.Range(.Cells(5, lngCol), .Cells(lngLastRow, lngCol + 2)).FillDown
End With
End If
End If
Next
Application.ScreenUpdating = True
End Sub
|

07-21-2009, 07:53 PM
|
|
Registered User
|
|
Join Date: 06 Feb 2005
Posts: 16
|
|
|
Re: Apply default chart to multiple worksheets?
thank you so much. This is awesome
|
 |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|