+ Reply to Thread
Results 1 to 9 of 9

Dynamic Excel Chart: Pulling Data from Two Different Tables (VBA?)

  1. #1
    Registered User
    Join Date
    10-14-2015
    Location
    East Coast
    MS-Off Ver
    2013
    Posts
    69

    Dynamic Excel Chart: Pulling Data from Two Different Tables (VBA?)

    Hi All,

    I'm having some trouble in trying to create a dynamic chart that pulls data from two different tables based upon the value of a combobox. So far, i've had to create each chart manually, name it, and call it via vba based on the value of a cell - this is very time consuming, as i have many charts..

    I would like to know how to change the series of the created chart based upon the value of the combobox, and pull data from the appropriate table using vba. I've attached an example worksheet to give you a better understanding of my problem, and the VBA code and method i've used to date.

    When posting a solution, please use comments in your code - really trying my best to learn this stuff!

    Thanks everyone!

    Best,
    Chris
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Dynamic Excel Chart: Pulling Data from Two Different Tables (VBA?)

    you really dont need VBA to achieve what you are asking but as you asked for a VBA specific response

    heres my code and attached file
    i deleted all your other charts and just left one and named it chart 1

    the title is based on cell o6 so thats why it isnt in the code

    Please Login or Register  to view this content.
    Attached Files Attached Files
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Dynamic Excel Chart: Pulling Data from Two Different Tables (VBA?)

    so this is the main line of code for everything else
    Please Login or Register  to view this content.
    this is just the syntax for the data series
    Please Login or Register  to view this content.
    this bit sets the range
    Please Login or Register  to view this content.
    starting cells of range begins at A12 then offset by the number generated from dropdown box...ie if it is 3 it drops down 3 rows then 3 columns
    likewise for end range of range...except 7 columns

    example
    option 5, drops down 6 lines from 12 = 12+6 = 18
    making the range ("D18:H18")

    Maximum value would be pretty self explanatory if you understand the everything else part
    Last edited by humdingaling; 10-16-2015 at 01:41 AM. Reason: wording

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Dynamic Excel Chart: Pulling Data from Two Different Tables (VBA?)

    if you really want to get fancy with your dynamic's

    Please Login or Register  to view this content.
    this code will copy the color scheme you have on table to the chart

  5. #5
    Registered User
    Join Date
    10-14-2015
    Location
    East Coast
    MS-Off Ver
    2013
    Posts
    69

    Re: Dynamic Excel Chart: Pulling Data from Two Different Tables (VBA?)

    Hey thanks for the reply - ALMOST got it.

    For your example, the X axis does not change.

    For the "Maximum Value" chart - i'd like the x-axis to be the following: Option 1, Option 2, Option 3, Option 4, Option 5
    For everything else, the x-axis should be : COA1, COA2, COA3, COA4, COA 5

  6. #6
    Registered User
    Join Date
    10-14-2015
    Location
    East Coast
    MS-Off Ver
    2013
    Posts
    69

    Re: Dynamic Excel Chart: Pulling Data from Two Different Tables (VBA?)

    Oh nevermind, just modified the code a little to reference the values...

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-14-2015
    Location
    East Coast
    MS-Off Ver
    2013
    Posts
    69

    Re: Dynamic Excel Chart: Pulling Data from Two Different Tables (VBA?)

    Hold on, now what if i want to pull this data from a different worksheet? I thought I had that down but I guess not....I've attached another example workbook highlighting this problem (its slightly different than the one before). The code is also below.


    Please Login or Register  to view this content.
    I keep getting a "method range of object _global failed" error

  8. #8
    Registered User
    Join Date
    10-14-2015
    Location
    East Coast
    MS-Off Ver
    2013
    Posts
    69

    Re: Dynamic Excel Chart: Pulling Data from Two Different Tables (VBA?)

    Please disregard, problem solved - and that was the wrong code - noob move on my part

  9. #9
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Dynamic Excel Chart: Pulling Data from Two Different Tables (VBA?)

    good to see you fixed the problem yourself

    If that takes care of your original question which i think it does, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 02-27-2015, 05:23 PM
  2. pulling data from web with dynamic url
    By Powermaniac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2014, 02:49 PM
  3. Uploading data into tables with a button click & pulling back the data from the table
    By tvsreekanth in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-27-2013, 07:29 AM
  4. Replies: 4
    Last Post: 05-24-2011, 03:11 AM
  5. Pulling data from several tables into one sheet?
    By Grim46 in forum Excel General
    Replies: 2
    Last Post: 12-06-2010, 12:45 PM
  6. Excel Tables dynamic data copying
    By gigiw1986 in forum Excel General
    Replies: 1
    Last Post: 04-24-2010, 11:12 AM
  7. Help with Excel tables to copy dynamic data update
    By gigiw1986 in forum Excel General
    Replies: 1
    Last Post: 04-24-2010, 06:54 AM

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.6.0 RC 1