+ Reply to Thread
Results 1 to 18 of 18

VB Copy embedded Graphs

Hybrid View

PhatPhil VB Copy embedded Graphs 11-25-2010, 07:10 AM
Andy Pope Re: VB Copy embedded Grpahs 11-25-2010, 08:33 AM
PhatPhil Re: VB Copy embedded Grpahs 11-25-2010, 09:25 AM
Andy Pope Re: VB Copy embedded Grpahs 11-25-2010, 09:39 AM
PhatPhil Re: VB Copy embedded Graphs 11-25-2010, 10:48 AM
  1. #1
    Registered User
    Join Date
    11-12-2009
    Location
    Derby, England
    MS-Off Ver
    Excel 2000
    Posts
    22

    VB Copy embedded Graphs

    I am trying to create a generic tool to analyse any Excel file so that the user can select what worksheets need to be copied to a new excel file. The tool is designed to remove all macro and formulas. By Copy and PasteSpecial Values and Formats I am close to achieving my goal. The issue I have is embedded graphs in worksheets are not copied.

    How do I copy Embedded Grpahs with VB.
    Last edited by PhatPhil; 11-29-2010 at 05:03 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: VB Copy embedded Grpahs

    First copy the range including those cells covered by the chart.
    Paste to the new sheet.
    The re-copy and pastespecial the values.

    The chartobject will still reference the original cells so you either need to update the chart data references or replace them with static array values.

    If you create a copy of the worksheet the chart references will update automatically. You could then copy/pastespecial the cell contents
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    11-12-2009
    Location
    Derby, England
    MS-Off Ver
    Excel 2000
    Posts
    22

    Re: VB Copy embedded Grpahs

    Andy thanks for responding.

    There is where I am getting confused, I am copy the whole Worksheet which I would presume would include the range associated with the graph. As I am designing a generic tool the graph could be any where on the worksheet.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: VB Copy embedded Grpahs

    are you copying the sheet or all the cells?

    It maybe helpful if you posted a workbook example and code.

    You can also check the setting for "copy, cut, sort objects with cells." via Tools > Options > Edit.

    Cut, copy, and sort objects with cells Keeps graphic objects, buttons, text boxes, drawn objects, and pictures with their associated cells whenever you cut, copy, filter, or sort on a worksheet.

  5. #5
    Registered User
    Join Date
    11-12-2009
    Location
    Derby, England
    MS-Off Ver
    Excel 2000
    Posts
    22

    Lightbulb Re: VB Copy embedded Graphs

    I missed the trick with your post. I was using Paste Special To Paste the Values and then the Formats which gave me the worksheet but excluding the graph. I am now using 'Activesheet Paste' which is now transfering all the data and then Pastespecial Values which is removing all the formulas.

    The issue I have now is although the graph is present, the source data is linked to donating excel file not the new one I created which you mentioned would be a problem in your first post.

    You mentioned copying the worksheet, I am using the code 'cells select' and 'selection copy' to copy the original is there some better VB code which does the copying.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: VB Copy embedded Graphs

    This will create a copy worksheet at the end of the workbook.

    activeworkbook.Worksheets("Sheet1").copy after:=activeworkbook.Sheets(activeworkbook.Sheets.Count)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1