I am using the code below to add a chart using a dynamic row length. However teh chart keeps skipping over the data in column B and does not include it in the chart. Also, the chart begins with a date that is not in the data range-how can I make that correspond to the data range?
Any ideas on why column B is being skipped?
Code:Dim charrange As Range Set charrange = Range("a4:a65536") Dim lastcharrow As Long With charrange lastcharrow = charrange.Find("*", [a4], xlValues, xlPart, xlByRows, xlPrevious).Row End With Range(Cells(3, 1), Cells(lastcharrow, 6)).Select ActiveSheet.Shapes.AddChart.Select ActiveChart.SetSourceData Source:=ActiveSheet.Range(Cells(3, 1), Cells(lastcharrow, 6)) ActiveChart.ChartType = xlXYScatterSmoothNoMarkers ActiveChart.SeriesCollection(1).Delete With ActiveChart.Parent .Left = 100 .Width = 500 .Top = 50 .Height = 300 End With
Last edited by nsorden; 08-12-2009 at 10:54 AM.
can you post example of your data layout.
I am an idiot. The linewas eliminating the column B data. I have also been able to set the axes limits to correspond to ranges.Code:ActiveChart.SeriesCollection(1).Delete
The following code enables dynamic axis ranges. Where chrtd is the sheet name and the respective cells contain max and min formulas for the data range.
Code:ActiveChart.Axes(xlCategory).MinimumScale = chrtd.Range("e2") ActiveChart.Axes(xlCategory).MaximumScale = chrtd.Range("f2") ActiveChart.Axes(xlValue).MinimumScale = chrtd.Range("b2") ActiveChart.Axes(xlValue).MaximumScale = chrtd.Range("c2")
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks