PC Review


Reply
Thread Tools Rate Thread

Chart Source when copying sheets to new file.

 
 
Keithlo
Guest
Posts: n/a
 
      16th Mar 2009
I am using VBA to copy select sheets to a new file and saving that new file.
Some sheets have charts, others the source for those charts. But the charts
in the new file point back to the original file, even though I have also
copied the source sheets into the new file with the same command using this
code:

Dim mySheet As Worksheet
Dim sheetList As Variant

ReDim sheetList(1 To ActiveWorkbook.Sheets.Count)
i = 0 'initialize variable
For Each mySheet In ActiveWorkbook.Sheets
If mySheet.Name <> "CHARTS (2)" And mySheet.Name <> "TABLE" Then
i = i + 1
sheetList(i) = mySheet.Name
End If
Next
ReDim Preserve sheetList(1 To i)
Sheets(sheetList).Copy

Is there any way to make the new charts get their source from the new source
sheets, or do I have to use SaveCopyAs and save the entire file instead?

Thanks,

Keithlo
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      16th Mar 2009
As far as I know, you can't do what you are trying to do.

You can do all kinds of things like pasting link (and of course the chart)
into PowerPoint or Word, and then when you update the Excel data, the chart
is updated appropriately. That's very different from what you are describing
though.

Again you can't do what you described unless maybe you do some operations on
the active Excel file (delete Sheets, or whatever), save the file and rename
the file. That should be essentially the same thing as copy/paste, right.

This is a good site for tons of chart-related info.
http://www.contextures.com/charts.html

Regards,
Ryan---

--
RyGuy


"Keithlo" wrote:

> I am using VBA to copy select sheets to a new file and saving that new file.
> Some sheets have charts, others the source for those charts. But the charts
> in the new file point back to the original file, even though I have also
> copied the source sheets into the new file with the same command using this
> code:
>
> Dim mySheet As Worksheet
> Dim sheetList As Variant
>
> ReDim sheetList(1 To ActiveWorkbook.Sheets.Count)
> i = 0 'initialize variable
> For Each mySheet In ActiveWorkbook.Sheets
> If mySheet.Name <> "CHARTS (2)" And mySheet.Name <> "TABLE" Then
> i = i + 1
> sheetList(i) = mySheet.Name
> End If
> Next
> ReDim Preserve sheetList(1 To i)
> Sheets(sheetList).Copy
>
> Is there any way to make the new charts get their source from the new source
> sheets, or do I have to use SaveCopyAs and save the entire file instead?
>
> Thanks,
>
> Keithlo

 
Reply With Quote
 
Keithlo
Guest
Posts: n/a
 
      17th Mar 2009
Ok. Thanks for the reply and link.

Keithlo

"ryguy7272" wrote:

> As far as I know, you can't do what you are trying to do.
>
> You can do all kinds of things like pasting link (and of course the chart)
> into PowerPoint or Word, and then when you update the Excel data, the chart
> is updated appropriately. That's very different from what you are describing
> though.
>
> Again you can't do what you described unless maybe you do some operations on
> the active Excel file (delete Sheets, or whatever), save the file and rename
> the file. That should be essentially the same thing as copy/paste, right.
>
> This is a good site for tons of chart-related info.
> http://www.contextures.com/charts.html
>
> Regards,
> Ryan---
>
> --
> RyGuy
>
>
> "Keithlo" wrote:
>
> > I am using VBA to copy select sheets to a new file and saving that new file.
> > Some sheets have charts, others the source for those charts. But the charts
> > in the new file point back to the original file, even though I have also
> > copied the source sheets into the new file with the same command using this
> > code:
> >
> > Dim mySheet As Worksheet
> > Dim sheetList As Variant
> >
> > ReDim sheetList(1 To ActiveWorkbook.Sheets.Count)
> > i = 0 'initialize variable
> > For Each mySheet In ActiveWorkbook.Sheets
> > If mySheet.Name <> "CHARTS (2)" And mySheet.Name <> "TABLE" Then
> > i = i + 1
> > sheetList(i) = mySheet.Name
> > End If
> > Next
> > ReDim Preserve sheetList(1 To i)
> > Sheets(sheetList).Copy
> >
> > Is there any way to make the new charts get their source from the new source
> > sheets, or do I have to use SaveCopyAs and save the entire file instead?
> >
> > Thanks,
> >
> > Keithlo

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
One Chart, Same Data ranges, different source sheets Greg in CO Microsoft Excel Charting 4 12th Mar 2010 02:57 PM
Copying sheets from one file to another and keeping the formulas.. =?Utf-8?B?RXhjZWwgR3Jhc3Nob3BwYWg=?= Microsoft Excel Misc 3 17th Nov 2004 06:34 PM
Chart source data when copying from one workbook to another =?Utf-8?B?RHJldyBMZXR0aW5ndG9u?= Microsoft Excel Programming 5 22nd Oct 2004 12:15 AM
Chart Source Data Ranges Changing when Data Sheet updated from text file source. Tekn0 Microsoft Excel Charting 3 8th Jan 2004 04:45 PM
RE: Error Copying File or Folder - Access denied - The source file may be in use diasmith [MSFT] Microsoft Windows 2000 Security 0 30th Oct 2003 08:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:41 PM.