Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 06-28-2009, 08:34 PM
frankabe frankabe is offline
Registered User
 
Join Date: 28 Jun 2009
Location: boston, ma
MS Office Version:Excel 2003
Posts: 1
frankabe is becoming part of the community
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
Reply With Quote
  #2  
Old 07-03-2009, 04:15 AM
Jbentley Jbentley is offline
Forum Contributor
 
Join Date: 03 Apr 2007
Location: Auckland, New Zealand
MS Office Version:2007
Posts: 121
Jbentley has been very helpful
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
Reply With Quote
  #3  
Old 07-17-2009, 12:37 PM
frankcase frankcase is offline
Registered User
 
Join Date: 06 Feb 2005
Posts: 16
frankcase is becoming part of the community
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.
Attached Files
File Type: xls chart format example.xls (110.5 KB, 2 views)
Reply With Quote
  #4  
Old 07-18-2009, 06:30 AM
Andy Pope's Avatar
Andy Pope Andy Pope is offline
Forum Guru
 
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,207
Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding
Re: Apply default chart to multiple worksheets?

Should your chart not be a xy-scatter rather than a Line chart type?
__________________
Cheers
Andy
www.andypope.info
Reply With Quote
  #5  
Old 07-18-2009, 09:56 PM
frankcase frankcase is offline
Registered User
 
Join Date: 06 Feb 2005
Posts: 16
frankcase is becoming part of the community
Re: Apply default chart to multiple worksheets?

This is the correct file format for this type of dataset :-)
Reply With Quote
  #6  
Old 07-19-2009, 07:16 AM
Andy Pope's Avatar
Andy Pope Andy Pope is offline
Forum Guru
 
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,207
Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding
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.
Attached Files
File Type: xls 689495.xls (143.0 KB, 3 views)
__________________
Cheers
Andy
www.andypope.info
Reply With Quote
  #7  
Old 07-19-2009, 01:26 PM
frankcase frankcase is offline
Registered User
 
Join Date: 06 Feb 2005
Posts: 16
frankcase is becoming part of the community
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
Attached Files
File Type: xls Chart copy macro v2.xls (207.0 KB, 1 views)
Reply With Quote
  #8  
Old 07-20-2009, 06:36 AM
Andy Pope's Avatar
Andy Pope Andy Pope is offline
Forum Guru
 
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,207
Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding
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
__________________
Cheers
Andy
www.andypope.info
Reply With Quote
  #9  
Old 07-21-2009, 07:53 PM
frankcase frankcase is offline
Registered User
 
Join Date: 06 Feb 2005
Posts: 16
frankcase is becoming part of the community
Re: Apply default chart to multiple worksheets?

thank you so much. This is awesome
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Forum Jump