|
こんばんは
マクロブック名が「ABC.xls」ですよね?
これでメッセージを確認してみて下さい。
Sub シートのコピー()
Dim myBook As Workbook
Dim Bookname As String
Dim I As Long, j As Long
Dim Shname As String
With ThisWorkbook.Worksheets("Menu")
For j = 4 To 10 Step 3
For I = 5 To 29 Step 2
If .Cells(I, j).Value <> "" And .Cells(I, j - 1).Value <> "" Then
Shname = Trim(.Cells(I, j - 1).Value)
Exit For
End If
Next I
Next j
End With
For Each myBook In Workbooks '開かれたBookのチェック
If myBook.Name = ThisWorkbook.Name Then
Else
Bookname = myBook.Name
Exit For
End If
Next
MsgBox "コピー先ブック名:" & Workbooks(Bookname).Name & vbCrLf _
& "コピー元シート名:" & ThisWorkbook.Worksheets(Shname).Name
ThisWorkbook.Worksheets(Shname).Copy after:=Workbooks(Bookname).Sheets(1)
End Sub
|
|