我的代码将Matrix 1中的单元格中的文本复制到符合我在Matrix 2中的条件的所有单元格。但是我希望它只将它复制到符合我在Matrix 2中的标准然后停止的第一个单元格。 / p>
Private Sub CommandButton1_Click()
Dim i As Integer
Dim j As Integer
For j = 2 To 2
For i = 21 To 21
If Cells(i, j).Value > 0 Then
Cells(i, j).Value = Cells(i, j).Value - 1
Cells(i, j).Offset(0, -1).Select
End If
'as it says - for EACH - so it copies in aLL the cells'
'I can't Change the range though, cause there will come a Loop eventually'
For Each cell In Range("a1:aap15")
If cell.Interior.ColorIndex = 6 Then
If cell.Value = "" Then
cell.Value = ActiveCell.Value
End If
End If
Next
Next
Next
End Sub
答案 0 :(得分:0)
您可以使用 0 1 2 3 4 5 6 7
d0: 00 FF 00 FF 00 00 00 FF
d1: 1 3 7 0 0 0 0 0
d0: 00 FF FF FF 00 00 FF 00
d1: 1 2 3 6 0 0 0 0
d0: FF FF FF FF FF FF FF FF
d1: 0 1 2 3 4 5 6 7
d0: FF 00 00 00 00 00 00 00
d1: 0 0 0 0 0 0 0 0
d0: 00 00 00 00 00 00 00 00
d1: 0 0 0 0 0 0 0 0
命令退出for循环。看起来你想在这里添加它:
Exit For
注意:未经测试。如果您有任何问题,请告诉我