Mastrohead
New Member
- Joined
- May 28, 2011
- Messages
- 3
Hi to all I'm a new user.
I have a trouble, I have to create a polar chart on excel. To do this I create a VBA subroutine to simplify its creation (in my mind..). It is a very stupid operation , but probably due to my poorly experience with VBA, I'm not able tio run it!
Can any one help me?!!
hereafter the code:
Sub graph()
Dim c() As Variant
Dim s() As Variant
Dim vn, bw As Single
vn = 0.1
i = 0
Const st = 30
For bw = 0 To 360 Step st
ReDim Preserve c(0 To i)
ReDim Preserve s(0 To i)
c(i) = vn * Cos(Application.Radians(bw))
s(i) = vn * Sin(Application.Radians(bw))
i = i + 1
Next
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = c
ActiveChart.SeriesCollection(1).Values = s
ActiveChart.SeriesCollection(1).Name = "=""VN=01"""
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "titolo gr"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "xValori"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "yValori"
End With
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
End Sub
I have a trouble, I have to create a polar chart on excel. To do this I create a VBA subroutine to simplify its creation (in my mind..). It is a very stupid operation , but probably due to my poorly experience with VBA, I'm not able tio run it!
Can any one help me?!!
hereafter the code:
Sub graph()
Dim c() As Variant
Dim s() As Variant
Dim vn, bw As Single
vn = 0.1
i = 0
Const st = 30
For bw = 0 To 360 Step st
ReDim Preserve c(0 To i)
ReDim Preserve s(0 To i)
c(i) = vn * Cos(Application.Radians(bw))
s(i) = vn * Sin(Application.Radians(bw))
i = i + 1
Next
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = c
ActiveChart.SeriesCollection(1).Values = s
ActiveChart.SeriesCollection(1).Name = "=""VN=01"""
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "titolo gr"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "xValori"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "yValori"
End With
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlAutomatic
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
End Sub
Last edited: