+ Reply to Thread
Results 1 to 5 of 5

Selecting a graph using macro

Hybrid View

  1. #1
    Registered User
    Join Date
    01-29-2007
    Posts
    12

    Selecting a graph using macro

    Hello,

    What is the VBA code for selecting a chart to work on? For instance, the code for selecting a worksheet named "Dashboard" is:

    Sheets("Dashboard").Select

    What is the code for selecting a particular chart?

    Thanks.

  2. #2
    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
    Hi,

    Best way to learn is use the VBA recorder.

    Record selecting the chart and see what code it produces

    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 !!!

  3. #3
    Registered User
    Join Date
    01-29-2007
    Posts
    12
    i've tried that an i have the code for it---but i need to refer to a specific graph every time I run a macro. the line of code i have written will not let me refer to the name of the chart every time i run the macro.

  4. #4
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    You cna also use this code:

    ActiveSheet.ChartObjects("Chart1").Activate
    or
    ActiveSheet.ChartObjects(1).Activate

    Regards,
    Antonio

  5. #5
    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
    Try

    Sheets("dashboard").ChartObjects("Chart 2").Activate
    Change chart 2 to your chart name

    VBA Noob

+ 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