仕様が不明瞭だったので、
列AとBだけについて、列Cが存在する限り処理するものとする、
としました。
テスト1


テスト2


テスト3


VBA
1Private Sub CommandButton1_Click()
2 Dim r As Long, rr As Long, r_src As Long
3 Dim c As Long
4
5 With ActiveSheet
6 r = 2
7 Do While Not IsEmpty(.Cells(r, 3).Value)
8 For c = 1 To 2
9 If IsEmpty(.Cells(r, c).Value) Then
10 rr = r - 1
11 Do While IsEmpty(.Cells(rr, c).Value)
12 rr = rr - 1
13 Loop
14 .Cells(rr, c).Copy Destination:=.Range(.Cells(rr + 1, c), .Cells(r, c))
15 End If
16 Next
17 r = r + 1
18 Loop
19 End With
20
21End Sub
退会済みユーザー
2017/12/13 02:28