Hi, Kenneth,
Thank you for your advice.
I've never used CreateObject or WScript but used them to replace my previous code.
Now it looks like
Sub LoopThroughDirectory()
Dim MyFile As String
Dim erow
MyFile = Dir("C:\Users\ahozumi\Desktop\Business sheet\")
Do While Len(MyFile) > 0
If MyFile = "zmaster.xlsm" Then
Exit Sub
End If
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Workbooks.Open CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\Business sheet\" & MyFile
Range("A5", "K27").Copy ThisWorkbook.Sheet1.Range(Cells(erow, "A"), Cells(erow, "B"))
ActiveWorkbook.Close False
Loop
End Sub
But now I've got Compile error saying "Method or data member not found".
I thought I need Paste command but when I tried to insert .Paste
after .Copy, I got compile error...
So I used
ActiveSheet.Paste Destination:=Worksheets("sheet1").Range(Cells(erow, 1), Cells(erow, 2))
But again I got compile error...
Where should I insert paste command in this case..?
Thank you for your help.
Midori