+ Reply to Thread
Results 1 to 12 of 12

Need macro to update graphs

  1. #1
    Registered User
    Join Date
    10-11-2008
    Location
    New Jersey
    Posts
    8

    Need macro to update graphs

    I have multiple graphs that read from rows varying in length from 2 to 60 columns long, depending on user input. I need help in creating a macro that readjusts the graphs to read from smaller/larger data set.

    I created one that said: If user input = 1, then set graph to (A1:A1), If user input = 2, then (A1:B1), but this is really inefficient. Is there a better way? Thanks!
    Last edited by VBA Noob; 10-14-2008 at 03:10 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Have you tried using range names in your graphs, then in the macros, adjust the named ranges dependent on the user input, rather than changing the graph references?

    HTH

  3. #3
    Registered User
    Join Date
    10-11-2008
    Location
    New Jersey
    Posts
    8
    Richard, Thanks for replying. Thats a good idea but I am still runing into a problem:

    the code to reset the range name is something like this:

    Please Login or Register  to view this content.
    [/B]

    Excel generates this weird reference to cells (above) which I can't replicate. How can I get around it?

    In other words i need code that would say, if user input = 5, set name range to xxx.
    Last edited by VBA Noob; 10-13-2008 at 01:36 PM. Reason: Added code tags

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Use code like the following to set your range name.

    Please Login or Register  to view this content.
    HTH

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719
    I get all my charts made with the help of the following:

    http://www.andypope.info/charts.htm

    http://www.tushar-mehta.com/excel/charts/

    http://www.oaltd.co.uk/Excel/Default.htm

    http://www.peltiertech.com/Excel/Cha...mmySeries.html

    These are by no means the only ones available on the net.
    It sounds like Tushar Mehta has charts on his site you can download that meet your criteria.

    Good luck.

    John

  6. #6
    Registered User
    Join Date
    10-11-2008
    Location
    New Jersey
    Posts
    8
    Richard,

    Thanks for your help, but I am still getting stuck (last line of code below):

    Please Login or Register  to view this content.
    What am I doing wrong here? The last line of code doesn't work, and I've tried different things to fix it, and debugger still gives me a very confusing error message, something about "global object method failed".
    Last edited by VBA Noob; 10-14-2008 at 04:00 PM. Reason: Added code tags as per forum rules

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719
    Is the column reference right or is this a typo?

    Please Login or Register  to view this content.
    John

  8. #8
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    DaniilK,

    I've added the codes tags for you as per forum rules below. Next time you post please use the code tags to avoid being issued with an infraction

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  9. #9
    Registered User
    Join Date
    10-11-2008
    Location
    New Jersey
    Posts
    8

    Solved

    I've actually gotten it to work. Thanks to all for the help!

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    What's that [B] doing there?

    Rgds

  11. #11
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Richard,

    Guess the OP knows how to use bold tags but not code tags.

    I will tidy it up

    VBA Noob

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,719
    DaniilK
    I am still learning so would it be possible to show me what you did to make it work?

    Thanks and regards.

    John

+ 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. update macro
    By crizzle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2008, 02:27 PM
  2. Executing a macro within a macro
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2008, 02:38 PM
  3. Run macro in workbook B from a macro in Workbook A
    By Wizz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-28-2008, 08:41 AM
  4. macro for charting
    By rbottner in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-30-2007, 09:35 PM
  5. HELP: Using a macro to update links
    By test1986 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-24-2006, 09:15 AM

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