tags:

views:

19

answers:

1

Hi,

I am working on a task where I should fill in some data in an excel workbook (using .NET) and the existing chart objects would draw line graphs based on the given data. Unfortunately, a macro in the workbook throws an error "Unable to set MinimumScaleIsAuto property of Axis class".

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
    .MinimumScaleIsAuto = True
    .MaximumScaleIsAuto = True
    .BaseUnitIsAuto = True
    .MajorUnit = 2
    .MajorUnitScale = xlMonths
    .MinorUnitIsAuto = True
    .Crosses = xlAutomatic
    .AxisBetweenCategories = False
    .ReversePlotOrder = False
End With

I am a newbie to VBA, Excel charting and the original author of the excel file is not around. But since the excel file is in use since quite sometime (with users filling data manually), I doubt if I am doing something wrong with the automated data entry.

The X-axis is plotted with dates and the Y-axis with some floating point values.

This error has been bugging me since quite sometime and I am stuck. Can anybody please please help me out?

A: 

Thank you for the edit GSerg. I did figure out what was causing the issue. I am sending the dates as strings from my program as I didnt want the time component to appear along with the date. Excel does not consider these as dates but as strings, I guess. I wrote a small macro to convert each cell in the range using the CDate function and everything worked fine.

Sub ConvertStringsToDates(oRange As Range)
    For Each c In oRange.Cells
        c.Value = CDate(c.Value)
        c.NumberFormat = "dd-mmm-yy"
    Next
End Sub
sammy