質問するログイン新規登録

回答編集履歴

2

コード修正

2021/09/08 00:15

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -54,15 +54,16 @@
54
54
 
55
55
  j = 1 '貼付先の開始行
56
56
  For i = 2 To Sht1.Cells(Rows.count, 1).End(xlUp).Row
57
- If Sht1.Cells(i, 1).Value <> "3.変更" Then Exit For 'A列が"3.変更"でなければ次のループへ
57
+ If Sht1.Cells(i, 1).Value = "3.変更" Then
58
- Dim c As Range
58
+ Dim c As Range
59
- For Each c In Sht1.Range(Sht1.Cells(i, 2), Sht1.Cells(i, 5))
59
+ For Each c In Sht1.Range(Sht1.Cells(i, 2), Sht1.Cells(i, 5))
60
- If c.Interior.ColorIndex <> xlNone Then '背景色あり
60
+ If c.Interior.ColorIndex <> xlNone Then '背景色あり
61
- Sht1.Range(Sht1.Cells(i, 2), Sht1.Cells(i, 5)).Copy Destination:=Sht2.Cells(j, 1)
61
+ Sht1.Range(Sht1.Cells(i, 2), Sht1.Cells(i, 5)).Copy Destination:=Sht2.Cells(j, 1)
62
- j = j + 1
62
+ j = j + 1
63
- Exit For
63
+ Exit For
64
- End If
64
+ End If
65
- Next
65
+ Next
66
+ End If
66
67
  Next
67
68
 
68
69
  End Sub

1

コード修正

2021/09/08 00:15

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -54,6 +54,7 @@
54
54
 
55
55
  j = 1 '貼付先の開始行
56
56
  For i = 2 To Sht1.Cells(Rows.count, 1).End(xlUp).Row
57
+ If Sht1.Cells(i, 1).Value <> "3.変更" Then Exit For 'A列が"3.変更"でなければ次のループへ
57
58
  Dim c As Range
58
59
  For Each c In Sht1.Range(Sht1.Cells(i, 2), Sht1.Cells(i, 5))
59
60
  If c.Interior.ColorIndex <> xlNone Then '背景色あり