+ Reply to Thread
Results 1 to 3 of 3

Thread: Certain field from each sheet as data series for chart

  1. #1
    Registered User
    Join Date
    07-01-2009
    Location
    Warsaw, Poland
    MS-Off Ver
    Excel 2003
    Posts
    1

    Certain field from each sheet as data series for chart

    I want to create a chart that will get a value stored in specific field (always the same) from each sheet of my xls file. I would like it also if descriptions on X axis (January 2009, February 2009... etc.) were taken from sheet names.

    Is there any way to do this automatically so I won't have to copy field from each sheet into one sheet, etc.? I just want to have a nice plain chart as one of my sheets (in the tabs in the bottom of excel window), that will update dynamically with each sheet I add.

    Thank you in advance

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,335

    Re: Certain field from each sheet as data series for chart

    Nothing automatic will make that happen.

    You will need code at best, formula with manual entry at worst.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Guru JBeaucaire's Avatar
    Join Date
    03-21-2008
    Location
    Bakersfield, CA
    MS-Off Ver
    2010
    Posts
    19,190

    Re: Certain field from each sheet as data series for chart

    To help simplify this, here's a little function you can add to your sheet to make an easy list of your sheet names:
    Public Function SheetName(Index As Long)
        If Index <= Sheets.Count Then
            SheetName = Sheets(Index).Name
        Else
            SheetName = ""
        End If
    End Function
    How to install the UDF:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet

    The new function is installed and ready to use. It is used like this:

    =Sheetname(3)
    ...gives the sheetname of the third sheet in the book.

    To make it so the formula can list all your sheets without you manually changing numbers, in row 1 somewhere enter this:
    =Sheetname(ROW())
    ...then copy that down. When you run out of sheets it will simply return blank cells.

    If you decide to start your list in row 5, you need to convert the first value back to "1" to start the list, so that would be:
    =Sheetname(ROW()-4)

    Make sense so far?

    Now, use an INDIRECT() formula to use the list you just created to pull the same cell from the other sheets. Let's say you wanted cell A1 and your list above started in D5, then next to it in E5 put:
    =IF(D5 = "", "", INDIRECT("'" & D5 & "'!A1")
    ...and copy down.

    Now you have your data. Highlight it and create your chart.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    “None of us is as good as all of us” - Ray Kroc
    “Actually, I *am* a rocket scientist.” - JB (little ones 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.2.0