ExcelVBA do while loop循环的用法
1、ExcelVBA do while loop循环的用法
上次分享了VB中for循环的用法,这次给大家分享do while loop 的用法。
2、Sub aaa()
dim a
Do While a < 900
。。。中间加代码。。。
Loop
End Sub
当a小于900的时候,loop以内的代码循环。
3、这里就多分享几个实例给大家,都是我刚学的时候写的东西。
现在工作用得少了,只能给大家分享分享经验了。
4、解读一:
Do While Cells(c, "r") <> ""
ccc = ccc + 1
mj1 = Cells(c, "r") + mj1
c = c + 1
Worksheets("Sheet1").Cells(cccc, "i") = mj1
Loop
当单元格“r”c不为空时,循环以下代码。
5、解读二:
Do While a < 900
b = Cells(a + 2, "b")
If b = "" Then
b = "田埂"
End If
Columns("O:R").Replace _
What:=a, Replacement:=b, _
SearchOrder:=xlByColumns, MatchCase:=True
a = a + 1
Loop
当a小于900时,循环以下代码。其中
b = Cells(a + 2, "b")为赋值
If b = "" Then
b = "田埂"
End If为判断赋值
最后一个为替换和赋值。
6、具体用法已经给大家说了,也举了两个例子。
上次for循环也没有这么多例子。
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:95
阅读量:136
阅读量:28
阅读量:133
阅读量:103