回答編集履歴

2

コード修正

2021/09/08 00:15

投稿

hatena19
hatena19

スコア34084

test CHANGED
@@ -110,23 +110,25 @@
110
110
 
111
111
  For i = 2 To Sht1.Cells(Rows.count, 1).End(xlUp).Row
112
112
 
113
- If Sht1.Cells(i, 1).Value <> "3.変更" Then Exit For 'A列が"3.変更"でなければ次のループへ
113
+ If Sht1.Cells(i, 1).Value = "3.変更" Then
114
114
 
115
- Dim c As Range
115
+ Dim c As Range
116
116
 
117
- For Each c In Sht1.Range(Sht1.Cells(i, 2), Sht1.Cells(i, 5))
117
+ For Each c In Sht1.Range(Sht1.Cells(i, 2), Sht1.Cells(i, 5))
118
118
 
119
- If c.Interior.ColorIndex <> xlNone Then '背景色あり
119
+ If c.Interior.ColorIndex <> xlNone Then '背景色あり
120
120
 
121
- Sht1.Range(Sht1.Cells(i, 2), Sht1.Cells(i, 5)).Copy Destination:=Sht2.Cells(j, 1)
121
+ Sht1.Range(Sht1.Cells(i, 2), Sht1.Cells(i, 5)).Copy Destination:=Sht2.Cells(j, 1)
122
122
 
123
- j = j + 1
123
+ j = j + 1
124
124
 
125
- Exit For
125
+ Exit For
126
126
 
127
- End If
127
+ End If
128
128
 
129
- Next
129
+ Next
130
+
131
+ End If
130
132
 
131
133
  Next
132
134
 

1

コード修正

2021/09/08 00:15

投稿

hatena19
hatena19

スコア34084

test CHANGED
@@ -110,6 +110,8 @@
110
110
 
111
111
  For i = 2 To Sht1.Cells(Rows.count, 1).End(xlUp).Row
112
112
 
113
+ If Sht1.Cells(i, 1).Value <> "3.変更" Then Exit For 'A列が"3.変更"でなければ次のループへ
114
+
113
115
  Dim c As Range
114
116
 
115
117
  For Each c In Sht1.Range(Sht1.Cells(i, 2), Sht1.Cells(i, 5))