1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
Private Sub CommandButton1_Click() For i = Selection(1).Row To Selection(Selection.Count).Row '選択範囲の行でループ For ii = 8 To 100 If Cells(i, ii).Interior.Color = RGB(0, 0, 0) Then If ii - UserForm1.TextBox1.Value < 8 Then Exit For Cells(i, ii).Interior.ColorIndex = xlNone Cells(i, ii - UserForm1.TextBox1.Value).Interior.Color = RGB(0, 0, 0) End If If Cells(i, ii).Interior.Pattern = 15 Then If ii - UserForm1.TextBox1.Value < 8 Then Exit For Cells(i, ii).Interior.Pattern = xlPatternNone Cells(i, ii - UserForm1.TextBox1.Value).Interior.Pattern = 15 End If Next ii Next i End Sub Private Sub CommandButton2_Click() For i = Selection(1).Row To Selection(Selection.Count).Row '選択範囲の行でループ For ii = 100 To 8 Step -1 If Cells(i, ii).Interior.Color = RGB(0, 0, 0) Then If ii + UserForm1.TextBox1.Value > 100 Then Exit For Cells(i, ii).Interior.ColorIndex = xlNone Cells(i, ii + UserForm1.TextBox1.Value).Interior.Color = RGB(0, 0, 0) End If If Cells(i, ii).Interior.Pattern = 15 Then If ii + UserForm1.TextBox1.Value > 100 Then Exit For Cells(i, ii).Interior.Pattern = xlPatternNone Cells(i, ii + UserForm1.TextBox1.Value).Interior.Pattern = 15 End If Next ii Next i End Sub |