JohnMunich
JohnMunich

Reputation: 631

Excel macro 3D chart

i have the following data in one sheet:

x y offset

1 1 2

1 2 2

1 3 3

1 4 4

2 1 5

2 2 6

2 3 2

2 4 2

3 1 3

3 2 4

3 3 5

3 4 6

4 1 8

4 2 7

4 3 0

4 4 9 and i want to display the offsets in a 3 dimensional way using an excel macro. In other words, here x and y are the coordinates, offsets are the z values. I just want to get a surface/columns over the xy plane. I searched awhile in the internet, but don't find much useful stuffs. Could you give me any hints?

Thanks in advance,

John

Upvotes: 0

Views: 6616

Answers (1)

froeschli
froeschli

Reputation: 2880

If you reformat your data, you will be able to use a regular Excel diagram type (3D columns) to graph the data:

    1   2   3   4
1   2   2   3   4
2   5   6   2   2
3   3   4   5   6
4   8   7   0   9

enter image description here

VBA code:

Sub graphData()
    Range("D3:H7").Select
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.SetSourceData Source:=Range("'Tabelle1'!$D$3:$H$7")
    ActiveChart.ChartType = xl3DColumn
End Sub

You would have to set your range accordingly.

Upvotes: 1

Related Questions