我可能需要同时绘制3到16个回归。
目前我有16个按钮,每个按钮都需要点击绘图;第一,第二等......这显然是耗时的,我想做到这一点,所以一个按钮将运行所有的宏。我遇到的两个问题是我不能只调用Macro1,Macro2等...而且,我可能只有3个值要绘制,所以我需要按钮来识别有多少个点,并且相应的情节。
以下是我的第一点,除了范围外,其他15个相同:
Sub Macro1()
' Macro1 Macro
Dim n As Range
Set n = Worksheets("Data Input & Summary").Range("D67")
If Range("D14") <> 0 Then
Call Pre
Application.Run "ATPVBAEN.XLAM!Regress", Worksheets("analysis 1").Range(Range("F6"), Range("F6").End(xlDown).Offset(-n)), _
Worksheets("analysis 1").Range(Range("G6"), Range("G6").End(xlDown).Offset(-n)), False, False, 90, Worksheets("Regression").Range("$A$1") _
, False, False, False, False, , False
Call Post
Else
MsgBox "You do not have any points to plot.", vbExclamation
End If
End Sub
编辑: Pre()和Post()函数严格解锁并取消隐藏工作表以绘制值并重新锁定。
编辑2:这可能会受到打击,但这是我尝试做一个循环,目的是帮助消除与我的目标混淆。
Sub Regression()
Dim n As Range, i As Integer, j As Integer, k As Integer, m As Integer, o As Integer
If Range("B14") <> 0 Then
For o = 0 To ("B14") ' B14 is number of regressions to perform
For i = 4 To 19 Step 1
For j = 6 To 81 Step 4 ' Skipping 3 letters between
For k = 7 To 82 Step 4 ' Skipping 3 letters between
For m = 1 To 346 Step 23 ' Skipping every 23 numbers
Set n = Worksheets("Data Input & Summary").Range(Cells(67, i))
Call Pre
Application.Run "ATPVBAEN.XLAM!Regress", Worksheets("analysis 1").Range(Range(Cells(6, j)), Range(Cells(6, j)).End(xlDown).Offset(-n)), _
Worksheets("analysis 1").Range(Range(Cells(6, k)), Range(Cells(6, k)).End(xlDown).Offset(-n)), False, False, 90, Worksheets("Regression").Range(Cells(a, 1)) _
, False, False, False, False, , False
Next m, k, j, i, o
Call Post
Else
MsgBox "You do not have any points to plot.", vbExclamation
End If
End Sub