Sub 接合() Dim retu1 As Integer: retu1 = 4 Dim retu2 As Integer: retu2 = 0 Dim i1, i2, i3, i4 As Integer i3 = 0 i4 = 0 For i = 1 To 100 If Cells(retu1, 2) = "" Then If Cells(retu1 + 1, 2) <> "" Then Range(Cells(retu2, 2), Cells(retu1, 2)).Merge 'セル結合 Range(Cells(retu2, 2), Cells(retu1, 2)).UnMerge 'セル結合 For i2 = retu2 To retu1 - 1 Dim b As Border Set b = Range(Cells(i2, 5), Cells(i2, 6)).Borders(xlEdgeBottom) ' 上側の罫線 b.LineStyle = xlDash Next i2 End If retu1 = retu1 + 1 Else If i4 > 9 Then i4 = 0 i3 = i3 + 1 End If Cells(retu1, 7) = Worksheets("sheet2").Cells(3 + i3, 5 + i4) i4 = i4 + 1 retu2 = retu1 retu1 = retu1 + 1 End If Next i End Sub