|
つまり、最初のコピー以外は日付の行を入れたくない、というわけですね。
Sub MyData_Copy()
Dim BAry As Variant
Dim DCnt As Integer, i As Integer
Dim MyB As Workbook, MyS As Worksheet
Dim Ad As String '追加
BAry = Array("出勤簿1.xls", "出勤簿2.xls", "出勤簿3.xls")
DCnt = Day(DateSerial(Year(Date), Month(Date) + 1, 0)) + 1
Application.ScreenUpDating = False
With ThisWorkbook
.WorkSheets("Sheet1").Cells.ClearContents
For i = 0 To 2
Set MyB = Workbooks.Open(.Path & "\" & BAry(i))
Set MyS = MyB.WorkSheets("Sheet1")
If i = 0 Then
Ad = "A1"
Else
Ad = "A2"
End If
MyS.Range(Ad, MyS.Range("A65536").End(xlUp)) _
.Resize(, DCnt).Copy .WorkSheets("Sheet1") _
.Range("A65536").End(xlUp).Offset(1)
MyB.Close False: Set MyS = Nothing: Set MyB = Nothing
Next i
.WorkSheets("Sheet1").Rows(1).Delete xlShiftUp
End With
Application.ScreenUpDating = True
End Sub
で、どうかな ?
|
|