|
そんなにたくさんのフィールドがあるなら、ループで追加していく方が
すっきりすると思います。こんな感じで
Sub T_Mth()
Dim i As Long
Dim dbs As DAO.Database
Dim rcs As DAO.Recordset, rcs2 As DAO.Recordset
Set dbs = OpenDatabase("D:\総括表.mdb")
Set rcs = dbs.OpenRecordset("T_Mth上期")
Set rcs2 = dbs.OpenRecordset("T_Mth下期")
With Worksheets("Mth")
rcs.AddNew
For i = 0 To rcs.Fields.Count - 1
rcs(i) = .Cells(i + 2, 7).Value
Next i
rcs.Update
rcs2.AddNew
For i = 0 To rcs2.Fields.Count - 1
rcs2(i) = .Cells(i + 182, 7).Value
Next i
rcs2.Update
End With
rcs.Close: rcs2.Close: dbs.Close
Set rcs = Nothing: Set rcs2 = Nothing: Set dbs = Nothing
End Sub
|
|