The following code works for me under Excel 2003
Sub Chart2Dsurface()
Dim sArea As Range
Dim i As Integer
Dim Nseries As Integer
Dim myChart As Chart
Set sArea = Application.InputBox(prompt:="Select range:", Type:=8)
Nseries = sArea.Rows.Count - 1
Set myChart = Charts.Add
With myChart
.SetSourceData Source:=sArea
.Name = "Pippo"
.ChartType = xlSurface
.Location where:=xlLocationAsObject, Name:="Sheet2"
End With
End Sub
--
John Green - Excel MVP
Sydney
Australia
"y" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi John and thank you for your answer,
>
> I posted my question because I used the macro recorder to initialize the macro, but I'm not able to
> run it again!
>
> I serched via google "xlSurface group:*Excel*" and it seems to me that Surface2D chart are hard to
> manage.
>
> I want an instruction to by-pass the error 1004 that VBA returns to me whan it runs the following
> lines of code:
>
> Sub Chart2Dsurface()
>
> Dim sArea As Range
> Dim i As Integer
> Dim Nseries As Integer
>
> Set sArea = Application.InputBox(prompt:="Select range:", Type:=8)
> Nseries = sArea.Rows.Count - 1
> Charts.Add.Name = "pippo"
>
> >> Charts("pippo").ChartType = xlSurface << Error 1004 !!!
>
> Application.WorksheetFunction.Chart.Activate
>
> Thanks Alex.
>
> John Green wrote:
>
> > Alex,
> >
> > I'm not sure what you are asking, but if you use the macro recorder while creating a chart you get something like the following.
> >
> > Charts.Add
> > ActiveChart.ChartType = xlColumnClustered
> > ActiveChart.SetSourceData Source:=Sheets("Sheet2").Range("C26:C30")
> > ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet2"
> >
> > Is this the style of code that is causing your error?
> >
>
|