|
>> MsgBoxでは、正常に見えます。
>これは本当ですよね?
はい、間違いありません。
>
>Shnameは数字ですか?
日本語です。
結局、次のようにしましたが、現象は変わりません。
Sub シートのコピー()
Dim myBook As Workbook
Dim Bookname As String
Dim I As Long, j As Long
Dim Shname As String
For j = 4 To 10 Step 3
For I = 5 To 29 Step 2
Sheets("Menu").Select
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
For Each myBook In Workbooks '開かれたBookのチェック
If myBook.Name = ThisWorkbook.Name Then
Else
Bookname = myBook.Name
Exit For
End If
Next
MsgBox (Bookname & " " & Shname)
'Workbooks(Bookname).Worksheet(Shname).Select
'Sheets(Shname).Copy after:=Workbooks(Bookname).Sheets(1)
ThisWorkbook.Sheets(CStr(Shname)).Copy _
before:=Workbooks(Bookname).Sheets(1)
End Sub
|
|