伙计 - 我已经测试了这一堆,似乎无法解决问题:
我在下面的参数应该只运行用户在userform上签出的月份。
Private Sub UpdateActuals_Click()
Dim p As Integer
Dim i As Integer
For i = 1 To 12
If Me.Controls("Month" & i).Value = True Then
For p = 1 To 12
Dim wkb As Workbook
Dim wks As Worksheet
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.AskToUpdateLinks = False
Set wkb = Workbooks.Open(Me.Controls("Location" & p))
Set wks = wkb.Sheets("Training1")
wks.Range("Start:Finish").Copy
ThisWorkbook.Sheets("2017 Actuals").Cells(5, i + 1).PasteSpecial xlPasteValues
wkb.Close
Application.DisplayAlerts = True
Application.AskToUpdateLinks = True
Application.ScreenUpdating = True
i = i + 1
Next p
End If
Next i
End Sub