K
klm
The following macro is supposed to generate a rotating straight line, but it
is not.
Please note that "circular reference" FunctionKey(F9) is used here.
Can you explain why and how to fix it, if you can, please.
Sub RotatingLine()
' I want to creat a rotating line by changing the slope in cell(G4) with
incremental change in cell(G6).
' But the line is not straight.
With Application
.Iteration = True
.MaxIterations = 1
.MaxChange = 0.001
End With
Range("E3") = "x"
Range("F3") = "y"
Range("G3") = "m"
Range("H3") = "b"
Range("E4") = "12"
Range("F4") = "40"
Range("G4") = "=G4+G6"
Range("H4") = "=F4-E4*G4"
Range("G5") = "incr m chng"
Range("G6") = "-15"
Range("A1") = 1
Range("A1:A20").Select
Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1, Trend:=False
Range("B1") = "=A1*$G$4+$H$4"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B20"), Type:=xlFillDefault
Range("A1:B20").Select
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:B20"),
PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
ActiveChart.HasLegend = False
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = -1000
.MaximumScale = 1000
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub
is not.
Please note that "circular reference" FunctionKey(F9) is used here.
Can you explain why and how to fix it, if you can, please.
Sub RotatingLine()
' I want to creat a rotating line by changing the slope in cell(G4) with
incremental change in cell(G6).
' But the line is not straight.
With Application
.Iteration = True
.MaxIterations = 1
.MaxChange = 0.001
End With
Range("E3") = "x"
Range("F3") = "y"
Range("G3") = "m"
Range("H3") = "b"
Range("E4") = "12"
Range("F4") = "40"
Range("G4") = "=G4+G6"
Range("H4") = "=F4-E4*G4"
Range("G5") = "incr m chng"
Range("G6") = "-15"
Range("A1") = 1
Range("A1:A20").Select
Selection.DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
Step:=1, Trend:=False
Range("B1") = "=A1*$G$4+$H$4"
Range("B1").Select
Selection.AutoFill Destination:=Range("B1:B20"), Type:=xlFillDefault
Range("A1:B20").Select
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:B20"),
PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
ActiveChart.HasLegend = False
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = -1000
.MaximumScale = 1000
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub