我有這個代碼到目前爲止在兩個文件之間傳輸。如何檢查目標工作簿是否已打開?我試過IsWorkbookOpen(),但它說「函數未定義」。檢查一個特定的工作簿是否打開
Sub Test2()
Dim rowCount As Long
Dim x As Integer
Dim y As Integer
Dim z As Integer
Dim a As Integer
a = 1
z = 5
x = 2
y = 16
ActiveWorkbook.Sheets("Results").Activate
rowCount = Cells(Rows.Count, "B").End(xlUp).Row
MsgBox "There are " & Workbooks.Count & " open workbooks!"
For Counter1 = 1 To 8
a = 1
z = 5
MsgBox "From :(" & a & "," & x & ") To:(" & z & "," & y & ")"
For Counter = 1 To rowCount
If IsWorkbookOpen("CMK & CPK Sheet (Rev2)") = True Then
MsgBox "Workbook is Open!"
Else
MsgBox "Workboook is Not Open!"
Workbooks("CMK & CPK Sheet (Rev2)").Sheets(3).Cells(z, y).Value = ActiveWorkbook.ActiveSheet.Cells(a, x).Value
z = z + 1
a = a + 1
Next Counter
y = y + 1
x = x + 1
Next Counter1
End Sub
是的,沒有這樣的功能。你可以嘗試加里做的事情。另一種方法是在「Object」變量中設置目標工作簿,以測試它是否打開。看我的帖子。 – L42