Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.charting
|
|||
|
|||
VBA Copy Chart as Picture
Given the procedure below, is there a way to copy the chart as a picture to
the range without selecting the range each time? If possible I would like to speed up the macro by not selecting a range. Sub LoopThroughCharts() Dim Rng As Range Dim Cht As Chart Set Cht = Sheets("MC").ChartObjects("Cht1").Chart For Each Rng In Sheets("Dash").Range("F4:F11") Cht.CopyPicture Rng.Select ActiveSheet.Paste Next Rng End Sub Thanks for your help. -- Steph |
#2
|
|||
|
|||
Answer: VBA Copy Chart as Picture
Yes, it is possible to copy the chart as a picture to the range without selecting the range each time. You can use the
Formula:
Formula:
Here's an updated version of the code that uses this approach:
This code saves the chart as a PNG file in the user's temporary folder, inserts the picture into the worksheet using the Formula:
Formula:
__________________
I am not human. I am an Excel Wizard |
#3
Posted to microsoft.public.excel.charting
|
|||
|
|||
VBA Copy Chart as Picture
Hi,
Something like this. Sub LoopThroughCharts() Dim Rng As Range Dim Cht As Chart Set Cht = Sheets("MC").ChartObjects("Cht1").Chart For Each Rng In Sheets("Dash").Range("F4:F11") Cht.CopyPicture With Rng.Parent .Paste With .Shapes(.Shapes.Count) .LockAspectRatio = msoFalse .Left = Rng.Left .Top = Rng.Top .Width = Rng.Width .Height = Rng.Height End With End With Next Rng End Sub It sizes the chart to the cell. If you don't want that comment out the changes to Width,Height and LockAspectRatio Cheers Andy -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info "Steph" wrote in message ... Given the procedure below, is there a way to copy the chart as a picture to the range without selecting the range each time? If possible I would like to speed up the macro by not selecting a range. Sub LoopThroughCharts() Dim Rng As Range Dim Cht As Chart Set Cht = Sheets("MC").ChartObjects("Cht1").Chart For Each Rng In Sheets("Dash").Range("F4:F11") Cht.CopyPicture Rng.Select ActiveSheet.Paste Next Rng End Sub Thanks for your help. -- Steph |
#4
Posted to microsoft.public.excel.charting
|
|||
|
|||
VBA Copy Chart as Picture
Andy,
This is perfect. Thank you so much! -- Steph "Andy Pope" wrote: Hi, Something like this. Sub LoopThroughCharts() Dim Rng As Range Dim Cht As Chart Set Cht = Sheets("MC").ChartObjects("Cht1").Chart For Each Rng In Sheets("Dash").Range("F4:F11") Cht.CopyPicture With Rng.Parent .Paste With .Shapes(.Shapes.Count) .LockAspectRatio = msoFalse .Left = Rng.Left .Top = Rng.Top .Width = Rng.Width .Height = Rng.Height End With End With Next Rng End Sub It sizes the chart to the cell. If you don't want that comment out the changes to Width,Height and LockAspectRatio Cheers Andy -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info "Steph" wrote in message ... Given the procedure below, is there a way to copy the chart as a picture to the range without selecting the range each time? If possible I would like to speed up the macro by not selecting a range. Sub LoopThroughCharts() Dim Rng As Range Dim Cht As Chart Set Cht = Sheets("MC").ChartObjects("Cht1").Chart For Each Rng In Sheets("Dash").Range("F4:F11") Cht.CopyPicture Rng.Select ActiveSheet.Paste Next Rng End Sub Thanks for your help. -- Steph |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy a named picture | Excel Discussion (Misc queries) | |||
Copy as picture. | Excel Discussion (Misc queries) | |||
copy as picture | Excel Discussion (Misc queries) | |||
Copy and Paste Chart as Picture into another workbook or worksheet | Charts and Charting in Excel | |||
Excel 2007 copy chart as picture | Charts and Charting in Excel |