Get underlying range address of a chartobject in Excel

Enter1

New Member
Joined
Sep 3, 2014
Messages
8
Hello All,
Im currently working on a project where I have excel files that have atleast 60-100 graphs each for different parameters. I wanted to list the underlying cell location of these charts in a separate excel sheet. I know I can do the opposite using VBA (specify where a chart can be placed at a desired range in a sheet).
For example I have a graph - chartobject above a range - E3:I13 , I would like to know if we can use VBA to get that underlying range address.

Unable to find a fix to this:(, if one of you can help then that would be of great help:).

Thanks.
 

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,166
This creates a worksheet with a list of all your charts and their locations.

Code:
[color=darkblue]Sub[/color] Chart_List_Ranges()
    [color=darkblue]Dim[/color] wsDest [color=darkblue]As[/color] Worksheet, ws [color=darkblue]As[/color] Worksheet, cht [color=darkblue]As[/color] ChartObject, i [color=darkblue]As[/color] [color=darkblue]Long[/color]
    [color=darkblue]Set[/color] wsDest = Sheets.Add(After:=Sheets(Sheets.Count))
    wsDest.Range("A1:C1").Value = Array("Sheet", "Chart", "Range")
    i = 1
    [color=darkblue]For[/color] [color=darkblue]Each[/color] ws [color=darkblue]In[/color] Worksheets
        [color=darkblue]If[/color] [color=darkblue]Not[/color] ws [color=darkblue]Is[/color] wsDest [color=darkblue]Then[/color]
            [color=darkblue]For[/color] [color=darkblue]Each[/color] cht [color=darkblue]In[/color] ws.ChartObjects
                i = i + 1
                wsDest.Range("A" & i).Value = ws.Name
                wsDest.Range("B" & i).Value = cht.Name
                wsDest.Range("C" & i).Value = Range(cht.TopLeftCell, cht.BottomRightCell).Address(0, 0)
            [color=darkblue]Next[/color] cht
        [color=darkblue]End[/color] [color=darkblue]If[/color]
    [color=darkblue]Next[/color] ws
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
 

Enter1

New Member
Joined
Sep 3, 2014
Messages
8
Excellent , thanks a lot "AlphaFrog" for the solution . It works like magic!!
 

Forum statistics

Threads
1,082,102
Messages
5,363,137
Members
400,720
Latest member
Pettel

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top