|
-
Jan 31st, 2006, 10:06 AM
#1
Thread Starter
New Member
Copying charts in Excel using VBA
I am very new to VBA and I need help with copying a chart from one workbook to another. The problem is that in the workbook I am copying from, the chart is a separate page. However, I want to copy just the chart and not have it be an entire page. Here is the code I am using:
VB Code:
DataBook.Sheets("Heat Transfer").Copy After:=OutputBook.Sheets(1)
VB Code:
DataBook.Sheets("Heat Flux").Copy After:=OutputBook.Sheets(2)
Code:
DataBook.Sheets("Skin Temperature").Copy After:=OutputBook.Sheets(3)
I think I am transfering the code into this message the right way but if it is awkward, I am sorry.
Thanks for any help, it will be appreciated
-Robert
-
Jan 31st, 2006, 10:38 AM
#2
Re: Copying charts in Excel using VBA
Knagulf
You could copy all the chgarts you need into the OutputBook workbook as seperate pages and after you have all them in that workbook you could then loop through the Charts collection and change the 'Location' such that each chart is an object on a particular worksheet.
Something like the following will achieve this.
VB Code:
Dim sSheetName As String
sSheetName = "Sheet2" 'whatever sheet you want the charts on
For Each chtMyChart In OutputBook.Charts
chtMyChart.Location Where:=xlLocationAsObject, Name:=sSheetName
Next chtMyChart
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Jan 31st, 2006, 11:14 AM
#3
Thread Starter
New Member
Re: Copying charts in Excel using VBA
I will try that and see if it works.
Thanks for the help.
--Robert
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|