日记首页
|
列表
|
添加日记
|
管理登陆
标题:vba,停止循环结束程序
<p>vba,停止循环结束程序:End</p><p>直接在msgbox后面使用end语句,比如<br>if a= 1 then<br> msgbox “错误退出”<br> end<br>end if </p><p><hr><p></p><p>Private Sub CommandButton1_Click()</p><p>Dim i, j</p><p> For i = 2 To 30<br> For j = 2 To 33<br>If TextBox1.Value = Cells(i, 1) Then<br> <br> <br> If DTPicker1.Value = Cells(1, j) Then<br> </p><p> Cells(i, j) = TextBox2.Value<br> End<br> End If<br> End If<br> Next<br> Next<br> <br>MsgBox ("ok")<br>End Sub</p><p><br></p><p><br></p><p><hr>Private Sub CommandButton1_Click()</p><p>Dim i, j, k</p><p> For i = 2 To 30<br> For k = 2 To 30<br> <br> For j = 2 To 33<br> <br>If TextBox1.Value = Cells(i, 1) Then</p><p>If TextBox3.Value = Cells(k, 2) Then<br> If i = k Then<br> <br> If DTPicker1.Value = Cells(1, j) Then<br> </p><p> Cells(i, j) = TextBox2.Value<br> End<br> End If<br> End If<br> End If<br> End If<br> Next<br> Next<br> Next<br> Next<br> <br>MsgBox ("ok")<br>End Sub<br></p>