VBA Error: Axes(xlValue).Select

Peni

New Member
Joined
Aug 18, 2005
Messages
26
Hi all.

I have a document with several views. In every view there is some data to be plotted. Two of those views are working correct. But plotting in the other two views result in an axes error:

hartCoord = "B5:" + ChartDate + "5,B7:" + ChartDate + "15"
ActiveSheet.ChartObjects("Chart 4").Activate
ActiveChart.Axes(xlValue).Select //error in this line
ActiveChart.ChartArea.Select
ActiveChart.SetSourceData Source:=Sheets("Data").Range(ChartCoord), PlotBy:=xlRows

This line "ActiveChart.Axes(xlValue).Select", what does it exactly do? I'm trying to find out what a possible error could be. What are typical errors sources for that line of code?

thanks
 

Some videos you may like

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
It's not necessary to select the value axis (or the ChartArea) to set the Source, so you can remove those 2 lines.

To see what the code would be for selecting the value axis on that chart, record a macro while doing it manually.
 

Peni

New Member
Joined
Aug 18, 2005
Messages
26
Well i deleted those two lines without rewriting anything else. The error is gone. But what are the effects of that change? Is the functionality changed now? I have no idea what those two lines do/did.
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Peni said:
Well i deleted those two lines without rewriting anything else. The error is gone. But what are the effects of that change? Is the functionality changed now? I have no idea what those two lines do/did.

As I sid before those lines aren't necessary. They simply select objects on the chart (like if you clicked them).
 

Watch MrExcel Video

Forum statistics

Threads
1,118,228
Messages
5,571,012
Members
412,353
Latest member
SofiaV
Top