Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default Copy embedded chart with updated data request

To all,

I have an embedded chart in worksheet 'test' in workbook testmacro.xls

I want the user to click on the chart, which will then copy the chart
(not as a picture) to a seperate workbook entitled testmacro2.xls into
worksheet 'test2' at range "B2".

How can I then make it so that any changes in the orginal embedded
chart in 'test' i.e. change in data range etc, are reflected in the
copied chart in testmacro2.xls?

Any help you could give me on this would be appreciated.

Regards

Joseph Crabtree
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Copy embedded chart with updated data request

Hi Joseph,

Right click your chart, Assign Macro...

Sub CopyMe()
Dim sBook As String, sSheet As String
Dim ans As Long
Dim ws As Worksheet
Dim wb As Workbook
Dim chtObj As ChartObject
Dim obj

sBook = "Book2" ' in my testing
'sBook = "testmacro.xls" ' uncomment
sSheet = "test2"

On Error Resume Next
Set obj = ActiveSheet.ChartObjects(Application.Caller)
If TypeName(obj) = "ChartObject" Then
Set wb = Workbooks("Book2")
If wb Is Nothing Then
MsgBox "the workbook " & sBook & " is not available"
Else
Set ws = wb.Worksheets(sSheet)

If ws Is Nothing Then
Set ws = wb.Worksheets.Add
ws.Name = "test2"
End If
wb.Activate
ws.Activate
For Each chtObj In ws.ChartObjects
If chtObj.TopLeftCell.Address = "$B$2" Then
ans = MsgBox("Delete exisiting chart", vbYesNoCancel)
If ans = vbYes Then
chtObj.Delete
ElseIf ans = vbCancel Then Exit Sub
End If
Exit For
End If
Next

ws.Range("B2").Select
obj.Chart.ChartArea.Copy
ActiveSheet.Paste
ws.Range("A1").Select

End If
End If

End Sub

Regards,
Peter T

"joecrabtree" wrote in message
...
To all,

I have an embedded chart in worksheet 'test' in workbook testmacro.xls

I want the user to click on the chart, which will then copy the chart
(not as a picture) to a seperate workbook entitled testmacro2.xls into
worksheet 'test2' at range "B2".

How can I then make it so that any changes in the orginal embedded
chart in 'test' i.e. change in data range etc, are reflected in the
copied chart in testmacro2.xls?

Any help you could give me on this would be appreciated.

Regards

Joseph Crabtree



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Copy embedded chart with updated data request

Typo -

change

Set wb = Workbooks("Book2")


to
Set wb = Workbooks(sBook)

Peter T

"Peter T" <peter_t@discussions wrote in message
...
Hi Joseph,

Right click your chart, Assign Macro...

Sub CopyMe()
Dim sBook As String, sSheet As String
Dim ans As Long
Dim ws As Worksheet
Dim wb As Workbook
Dim chtObj As ChartObject
Dim obj

sBook = "Book2" ' in my testing
'sBook = "testmacro.xls" ' uncomment
sSheet = "test2"

On Error Resume Next
Set obj = ActiveSheet.ChartObjects(Application.Caller)
If TypeName(obj) = "ChartObject" Then
Set wb = Workbooks("Book2")
If wb Is Nothing Then
MsgBox "the workbook " & sBook & " is not available"
Else
Set ws = wb.Worksheets(sSheet)

If ws Is Nothing Then
Set ws = wb.Worksheets.Add
ws.Name = "test2"
End If
wb.Activate
ws.Activate
For Each chtObj In ws.ChartObjects
If chtObj.TopLeftCell.Address = "$B$2" Then
ans = MsgBox("Delete exisiting chart", vbYesNoCancel)
If ans = vbYes Then
chtObj.Delete
ElseIf ans = vbCancel Then Exit Sub
End If
Exit For
End If
Next

ws.Range("B2").Select
obj.Chart.ChartArea.Copy
ActiveSheet.Paste
ws.Range("A1").Select

End If
End If

End Sub

Regards,
Peter T

"joecrabtree" wrote in message
...
To all,

I have an embedded chart in worksheet 'test' in workbook testmacro.xls

I want the user to click on the chart, which will then copy the chart
(not as a picture) to a seperate workbook entitled testmacro2.xls into
worksheet 'test2' at range "B2".

How can I then make it so that any changes in the orginal embedded
chart in 'test' i.e. change in data range etc, are reflected in the
copied chart in testmacro2.xls?

Any help you could give me on this would be appreciated.

Regards

Joseph Crabtree





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I preserve chart formatting when the source data is updated? JasenD Charts and Charting in Excel 3 June 19th 06 01:38 PM
Can't copy workseet with embedded chart JGeniti Excel Programming 0 December 7th 05 07:02 PM
Removing data from an automatically updated chart Reallydumb Charts and Charting in Excel 0 August 16th 05 01:57 AM
What if I DON'T want the chart to be updated when source data changes? arhooley Charts and Charting in Excel 2 June 9th 05 05:07 AM
Embedded chart along with DATA to powerpoint Hari Prasadh[_2_] Excel Programming 2 February 10th 05 08:54 AM


All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"