Search TeachExcel.com
TeachExcel.com
TE
Teach Excel MS Office Tutorials Excel Consulting Services Excel Forum
Excel Video Tutorials Excel Tips Free Excel Macros Excel Help Resources Contact TeachExcel
Video Tutorials
  • Free Macros
  • Excel Help Directory
  • Excel 2007 Resources
  • Keyboard Shortcuts
  • Excel Forum
  • Contact/About

Macros
Excel Tutorials For Macros

Get Values from a Chart


Bookmark and Share

This macro will pull the values from a chart in excel and list those values on another spreadsheet. This will get the source data from charts and graphs and list this data separately. This is an espcially important feature if you only have a chart but not the source data or if the source data was damaged but you still need it separate from the chart. This macro will work for source data that has been linked to or has been lost or simply resides on an external worksheet or workbook.

IMPORTANT
Create a new sheet titled ChartData  (this is where the chart data will be placed)

To run the macro simply select the chart from which you want to pull data, either an embedded chart or a chart on its own tab, and then run the macro and the source data will be placed in the "ChartData" worksheet.
Where to install the macro:  Module

Get Source Data from a Chart

Sub GetChartValues()

'This macro will retrieve the source data from a chart in excel
'This works for charts where the source data has been lost or
'damaged.
'Simply select the chart and run the macro - make sure to create a
'separate worksheet titled "ChartData" first though.
'
   Dim NumberOfRows As Integer
   Dim X As Object
   Counter = 2
   NumberOfRows = UBound(ActiveChart.SeriesCollection(1).Values)
   Worksheets("ChartData").Cells(1, 1) = "X Values"
   With Worksheets("ChartData")
      .Range(.Cells(2, 1), _
      .Cells(NumberOfRows + 1, 1)) = _
      Application.Transpose(ActiveChart.SeriesCollection(1).XValues)
   End With
   For Each X In ActiveChart.SeriesCollection
      Worksheets("ChartData").Cells(1, Counter) = X.Name
      With Worksheets("ChartData")
         .Range(.Cells(2, Counter), _
         .Cells(NumberOfRows + 1, Counter)) = _
         Application.Transpose(X.Values)
      End With
      Counter = Counter + 1
   Next
End Sub

Bookmark and Share


How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

      For Excel Versions Prior to Excel 2007
      Go to Tools > Macros > Visual Basic Editor

      For Excel 2007
      Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

    1. Go to the menu at the top of the window and click Insert > Module
    2. Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
    3. Go to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Go to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
    5. Go to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.



Similar Helpful Excel Resources

Huge Differences In Chart Values Screws My Bar Chart Scale Up. - Excel

View Content
Hi!

I have a table which has mainly values between 0 and 5000 and I made
bar chart from that data.

Then I have 1 value which is over 100 000. This ofcourse makes all
other bars way to small to be of any use.

Is there any way to "truncate" this 1 bar so it wouldn't mess up the
scale, but would show the right value anyway? Could I for example set
different scale from 0 to 5000 and then from 5000 to 120 000?

Regards,
Aki



Displaying Larger Values With Smaller Values In A Column Chart - Excel

View Content
I have two values that I'd like to compare in a Column Chart.

First Column... dates.

Second Column's cells showing values of .0470, .0784 for example.

Third Column's cells showing values of $50,000, $52,000 for example.

The problem I have is that the Third Column's Column Towers over the Second Column's Column... which is understandable due to the larger numbers being compared to the decimal numbers, but I'd like to have the Second column (decimal column) visible next to the Third Column.

Thank you very much

Displaying Larger Values With Smaller Values In A Column Chart - Excel

View Content
I have two values that I'd like to compare in a Column Chart.

First Column... dates.

Second Column's cells showing values of .0470, .0784 for example.

Third Column's cells showing values of $50,000, $52,000 for example.

The problem I have is that the Third Column's Column Towers over the Second Column's Column... which is understandable due to the larger numbers being compared to the decimal numbers, but I'd like to have the Second column (decimal column) visible next to the Third Column.

Thank you very much

Showing Values As A Percentage In A Bar Chart - But Keeping Scale As The Values - Excel

View Content
I currently have a set of data the is shown in a column chart. At the moment, the 'y' axis has the scale set to the values and each bar is shown as the value itself.

Is there anyway of showing the figure on the bar as a percentage of the total for that bit, whilst keeing the 'y' axis as the values?

Hope this makes sense??

Please note this is for a column chart, not bar chart

Troubles With Asigning X Values And Values To A Chart - Excel

View Content
The following code returns run-time error 1004 with message:
Method'SeriesCollection' of object '_Chart' failed. It stops on:
ActiveChart.SeriesCollection(k).XValues = rngX

I tried already many ways of building this, but it stil doesn't work.
The code inside pharentesis: Range( .. ) returns proper value
"A7:A2407" (which are not empty) and PreformName(i) returns proper
value.

The motivation for this code is analysing mesurement data, which is set
in A and B colmun. In EmptyIndex there are positions of empty spaces
between mesurements.

Help me please

For k = 1 To (UBound(EmptyIndex) - 1)
rngX = Worksheets(PreformName(i)).Range("A" &
(EmptyIndex(k) + 3) & ":A" & EmptyIndex(k + 1))
rngVal = Worksheets(PreformName(i)).Range("B" &
(EmptyIndex(k) + 3) & ":B" & EmptyIndex(k + 1))
rngName = Worksheets(PreformName(i)).Range("A5")

ActiveChart.SeriesCollection(k).XValues = rngX
ActiveChart.SeriesCollection(k).Values = rngVal
ActiveChart.SeriesCollection(k).Name = rngName
With ActiveChart.SeriesCollection(k).Border
.ColorIndex = ColorInd
.Weight = xlMedium
.LineStyle = xlContinuous
End With
With ActiveChart.SeriesCollection(k)
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = True
.MarkerSize = 3
.Shadow = False
End With
ColorInd = ColorInd + 1
Next k



Chart Values - Excel

View Content
Hey there all.

Just dropping in because I need help with what I think could be a pretty simple problem. I'm creating a series of line graphs based on tennis player rankings over several dates. As everyone knows, in tennis, rank 1 is the highest possible, so therefore, lower is better.

The best way I can explain the situation with my graph is that because it is 'smallest to largest,' it ascends. Therefore when a player improves their ranking, the position in the graph will drop, indicating that they've dropped.

Is there a way so I can get the graph to process data as if it were 'largest to smallest?' And therefore have the graph properly reflect improvement in a player's ranking?

Thanks,

Chart & Zero Values - Excel

View Content
Hi

In Excel 2003, I have a dynamic chart, where the Data Series is looking at a range of cells with the following formulae in them.

=IF(INDEX(Trends!1:65536,$AA$3+2,AB2)=0,"",INDEX(Trends!1:65536,$AA$3+2,AB2))

I'd like the chart to ignore any leading zero values, i.e. just start plotting the line once the value is > 0, hence I tried "" if true above, hoping that the chart would ignore the "", but the chart still draws a line along the bottom.

Is there a way to do this ?

Thanks for your help.

Kind Regards
Gav

Different X Values On Chart - Excel

View Content
I am building a benchmarking tool which allows the user to input values, and benchmark the performance against the existing values.

The values inputted are a range and can be from 10% to 20% to 0% to 100%.

The results are plotted on a chart.

My vba code currently displays out all the values in between the upper and lower ranges, so the range can vary. This is why the chart needs to be plotted via vba.

My problem is this:

The original values may begin at 20% and the new values begin at 40%, however when the results are plotted, both series will be plotted at the start of whatever series was plotted first, rather than at the correct position.

So in this example, I would want the first point on series 1 plotted at 20% and the first point on series 2 to be plotted at 40%, but at the moment they are both at 20%.

I have tried to give them unique x values via the .XValues property, but this doesnt seem to work...

Any thoughts?

Chart With #n/a Values - Excel

View Content

Zero Values In A Pie Chart - Excel

View Content
Hi

I currently have some data as shown below:

Item 1 0
Item 2 3
Item 3 6
Item 4 5
Item 5 0
Item 6 9

How can I exclude the zero items automatically, the data shown below is
going to change regulary and i do not want to have to keep change the source
data manually.

D




Random Tutorials
Net Present Value / Discounted Cash Flow Calculations
(Intermediate)
Extract Text from Cells - Intermediate Example
(Intermediate)
Introduction to Making Formulas in Excel
(Easy)
IF Statement Introduction & Using Nested IF's
(Easy)
HLOOKUP() Function - Introduction
(Intermediate)
AND(), OR(), and IF() Statements/Formulas
(Intermediate)
Submit Inquiry Here
  • Prices From $10
Name:*
E-mail:*
Request:*
The macro(s) on this page will be sent with the request.
Contact | Privacy Policy | Disclaimer
Copyright© 2012 TeachExcel.com