Sheets("作图数据").Rows("2:1048576").Clear
With obReg
.Global = True
.IgnoreCase = True
.Pattern = "[x]"
End With
Sheets("作图数据").Cells(2, 1).FormulaR1C1 = "=方程式!R2C2"
Sheets("作图数据").Cells(3, 1).FormulaR1C1 = "=R[-1]C+方程式!R2C4"
Sheets("作图数据").Cells(3, 1).AutoFill Destination:=Sheets("作图数据").Range(Sheets("作图数据").Cells(3, 1), Sheets("作图数据").Cells(length + 2, 1))
For i = 0 To 9
Sheets("作图数据").Cells(2, 2 + i).FormulaR1C1 = "=" & obReg.Replace(Sheets("方程式").Cells(2 + i, 1).Value, "RC[-" & i + 1 & "]")
Sheets("作图数据").Range(Sheets("作图数据").Cells(2, 2 + i), Sheets("作图数据").Cells(2, 2 + i)).AutoFill Destination:=Sheets("作图数据").Range(Sheets("作图数据").Cells(2, 2 + i), Sheets("作图数据").Cells(length + 2, 2 + i))
Next
ActiveWorkbook.Names.Add Name:="X_1", RefersToR1C1:="=OFFSET(作图数据!R1C1,0,0,方程式!R2C7,1)"
For j = 1 To 10
ActiveWorkbook.Names.Add Name:="Y_" & j, RefersToR1C1:="=OFFSET(作图数据!R1C" & j + 1 & ",0,0,方程式!R2C7,1)"
Next
Sheets("方程式").ChartObjects("图表 3").Activate
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MinimumScale = Sheets("方程式").Range("e2").Value
ActiveChart.Axes(xlValue).MaximumScale = Sheets("方程式").Range("f2").Value
ActiveChart.Axes(xlValue).MajorUnit = Sheets("方程式").Range("E5").Value
ActiveChart.Axes(xlValue).MinorUnit = Sheets("方程式").Range("F5").Value
ActiveChart.Axes(xlCategory).Select
ActiveChart.Axes(xlCategory).MinimumScale = Sheets("方程式").Range("b2").Value
ActiveChart.Axes(xlCategory).MaximumScale = Sheets("方程式").Range("c2").Value
ActiveChart.Axes(xlCategory).MajorUnit = Sheets("方程式").Range("C5").Value
ActiveChart.Axes(xlCategory).MinorUnit = Sheets("方程式").Range("D5").Value
End Sub
步骤四:
在方程式表中插入两个宏按钮,具体操作如下:
完成后效果如下:
步骤五:
将控件按钮分别对应关联到我们刚才粘贴的两段代码:
步骤六:
大功告成!只需在方程式一栏中填写自己想要作图的方程然后点击作图即可生成函数图像。
注意:当改变X、Y轴范围时点击作图按钮,只是改变方程时点击刷新按钮!!!
由于头条不能放置链接,如需要附件请私信我!
閱讀更多 樂享所知 的文章