问题描述
大家好,我是VBA的新手,并且找不到结束这个循环的方法。我已经尝试了几种解决方案但是我不得不重新启动应用程序。编码按照我的意愿运行,只是想结束无限循环。任何帮助都会非常感激
。谢谢
Sub Macro5()
将我的数据调暗为范围
Dim myCell As Range
设置myData = Range(Cells.Address)
每个myCell在我的数据中$
如果myCell.Value Mod 2 = 0并且myCell.Value> 0然后
myCell.Interior.ColorIndex = 37
ElseIf myCell.Value Mod 2 = 1然后
myCell.Interior.ColorIndex = 4
结束如果
下一步
结束子
Hi all, I am new to VBA and can't find a way to end this loop. I have tried several solutions but am stuk in a constant loop and have to restart application. The coding works how I want, just want to end infinite loop. Any help would be greatly appreciated. Thanks
Sub Macro5()
Dim myData As Range
Dim myCell As Range
Set myData = Range(Cells.Address)
For Each myCell In myData
If myCell.Value Mod 2 = 0 And myCell.Value > 0 Then
myCell.Interior.ColorIndex = 37
ElseIf myCell.Value Mod 2 = 1 Then
myCell.Interior.ColorIndex = 4
End If
Next
End Sub
这篇关于陷入循环,帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!