請教大大們,
下次程式是個下拉傳回資料程式, 程式把另一檔案資料傳回, 當程式運行中, 會自行開啟另一檔案, 傳回資料後, 該被開啟檔案會自行關聞, 現時我希望能做到程式必須於兩個檔案同時開啟下才能運行. 請大大們指導, 謝!!
Private Sub ComboBox1_Change()
With ComboBox1
i = .ListIndex
If i = -1 Then Exit Sub
ar = Array(Month(Date), Date, .List(i, 1), .List(i, 2), .List(i, 3), .List(i, 4), "", .List(i, 5))
Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(, 8) = ar
End With
End Sub
Private Sub ComboBox1_DropButtonClick()
Application.ScreenUpdating = False
fs = ThisWorkbook.Path & "\sal名冊.xlsm"
With Workbooks.Open(fs)
With .Sheets("人員名稱")
ar = .Range(.[A4], .[A3].End(xlDown).Offset(, 5))
With ComboBox1
.ColumnCount = 3
.List = ar
.ColumnWidths = "0,30,40"
End With
End With
.Close 0
End With
Application.ScreenUpdating = True
End Sub作者: 周大偉 時間: 2016-12-3 10:27
Private Sub ComboBox1_DropButtonClick()
Dim DataBook As Workbook
On Error Resume Next
Set DataBook = Workbooks("資料庫.xlsm")
On Error GoTo 0
If DataBook Is Nothing Then MsgBox "資料庫檔案未開啟! ": Exit Sub
With DataBook.Sheets("工作表1")
ar = .Range(.[A4], .[A3].End(xlDown).Offset(, 5))
With ComboBox1
.ColumnCount = 3
.List = ar
.ColumnWidths = "0,30,40"
End With
End With
End Sub作者: 周大偉 時間: 2016-12-3 13:23