+ Reply to Thread
Results 1 to 3 of 3

Thread: Find and Replace in Charts

  1. #1
    Registered User
    Join Date
    10-22-2010
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    5

    Find and Replace in Charts

    Hi,

    I am wondering if anyone knows how to find and replace on Excel charts??

    For example I have the following

    'Sheet1' Worksheet on Workbook 1
    'Results' Worksheet on Workbook 1

    'Sheet 2' Worksheet on Workbook 2
    'Results' Worksheet on Workbook 2

    I have copied a chart from 'Sheet 1' on Workbook 1 to 'Sheet 2' on Workbook 2.

    How can I replace the references on the Chart to 'Sheet 1' on Workbook 1 to 'Sheet 2' Workbook 2?

    I have about 25 charts I am looking to do this for so I am looking on tips that would allow me to do this quickly...Possibly a macro which works.

    Many thanks in advance.

    Sagar

  2. #2
    Forum Guru 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Vienna, VA, USA
    MS-Off Ver
    Excel 2003, 2007
    Posts
    2,257

    Re: Find and Replace in Charts

    Do you mean update range references that appear in the SERIES formulas?

    Install and run this code in your Workbook2, Worksheet2 code module. (This is suitable for a one-time update but is not highly robust against weird condtions.)

    ' Update all charts to use a different sheet reference
    Public Sub Update()
       Dim ch As ChartObject
       Dim s As Series
     
       For Each ch In ChartObjects
          For Each s In ch.Chart.SeriesCollection
                s.Formula = Replace(s.Formula, "Sheet1", "Sheet2")
          Next s
       Next ch
     
    End Sub
    Making the world a better place one fret at a time
    ||||||

    If someone helped you, please click on the star icon at the bottom of their post

    If your problem is solved, please update the first post:
    EDIT, Go Advanced button, set Prefix to SOLVED

    [code]
    ' Enclose code in tags like this
    [/code]

    Don't attach a screenshot
    --just attach your Excel file! It's easier and will let us experiment with your data, formulas, and code.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,349
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0