Graphing Last 10 rows of data


Posted by Scott Schuh on December 21, 1999 7:40 PM

I am wondering how I can take data in an excel sheet (400 rows, for example), and graph only the contents of the last 10 cells. I can't seem to find any VB function that does this.
Any help you could offer would be great!
Thanks in advance,
Scott Schuh

Posted by Ivan Moala on December 22, 1999 2:35 AM

Hi Scott,
Try something like this;
Assuming your data is in Column "A"

sub tester()

Dim Last10 As Range

Range("A1").Select
Set Last10 = Range(ActiveCell.End(xlDown).Offset(-10, 0), ActiveCell.End(xlDown)) '.Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range(Last10.Address), PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
End Sub

Ivan



Posted by FrankC on January 09, 2000 12:40 PM

From what I understood of your problem, you are not sure which your last 10 rows
will be.
To fix this, I recommend writing a macro that will read the value of each cell in that
row and convert it to a string (that is, text). Then check if this string is blank, i.e. = "".
If so, you know that's your last row, then subtract 10.

I don't know what your level of knowledge of macros is. I could go in more details.