Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Chart - Deleting Source Worksheets 1

Status
Not open for further replies.

PWD

Technical User
Jul 12, 2002
823
GB
Good morning, I have worksheets with charts that reference data from other worksheets and I want to, effectively, copy and Paste As Values so I can then delete the source worksheets. I've had a look and can't figure out how to do it.

After recording a macro I tried this but it didn't do what it did when I was recording it and just appears to duplicate what's already there.

Code:
    For Each Chart In ActiveSheet.ChartObjects
    Chart.Activate
    ActiveChart.PlotArea.Select
    ActiveChart.Paste
    Next Chart

Any ideas please?

Many thanks,
D€$
 
This seems to do it:-

Code:
    For Each Chart In ActiveSheet.ChartObjects
        Chart.Activate
        ActiveChart.CopyPicture
        ActiveChart.Paste
    Next Chart

Many thanks,
D€$
 
What your macro does is replace the chart with a picture of the chart. Is that what you want? It sounded like you wanted to copy the source data from the source worksheets and delete the source worksheets.
 
Hi zelgar, what we need to do is just present the finished item (the picture, I guess) for the target audience and not give them access to the source data. However, your post raised an interesting question, "What happened to the original chart?" Answer, "It's still there behind the picture!" It turns out that the data behind the charts is to be kept in the workbook, but what if I wanted to present just the chart worksheets in a separate workbook?

I guess that question is actually still unanswered!

So suggestions please.

Many thanks,
D€$
 
Hi,

When you COPY something, if you use the COPY in the Ribbon, there is an option to Copy As... and a choice of pictures. Once you get it down, you could record a macro shortcut.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
The following macro will create a new sheet and copy a picture of all of the charts to the new sheet.
Code:
Sub chartpic()
nowsheet = ActiveWorkbook.Name
Workbooks.Add
NewSheet = ActiveWorkbook.Name
Windows(nowsheet).Activate
place = 1
For Each Chart In ActiveSheet.ChartObjects
        Chart.Activate
        ActiveChart.CopyPicture
        X = ActiveChart.Parent.Height
        Windows(NewSheet).Activate
         Cells(place, 1).Select
         ActiveSheet.Paste
         place = place + Int(X / 13)
        Windows(nowsheet).Activate

    Next Chart
End Sub
 
Print the chart worksheets as PDF. Give PDF to target audience.

Copy/Paste chart as picture into .... Word document, PowerPoint, .JPG, .PNG whatever and give that to target audience.
 
Thanks zelgar; and then I could delete the original worksheet and rename the new one. Once saved on the network then it would be available to whomsoever required it! [bigsmile]

@mintjulip
I would probably SaveAs a pdf and still save that somewhere. Food for thought though.

Many thanks,
D€$
 
Unless this is a ONE TIME deal, and in my world, those are few, why would you delete source data/charts that could be used for follow-on work?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Hi Skip, initially this stemmed from some error when I was testing parts of macros that made it appear as if these charts had lost their links to their source worksheets. This is a slimmed-down copy of the original, master, workbook with fewer worksheets so we still have the relevant connections ready for next month's data.

Many thanks,
D€$
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top