|
怎么让这个程序中间可以停一下?怎么实现按一下cmdbutton才让运行一下?谢谢!
- Option Base 1
- Dim endRow As Integer
- Dim curRow As Integer
- Dim nextRow As Integer
- Private Sub cmd_Click()
- Dim i As Integer
- '若当前行存在
- If curRow Then
- For i = nextRow + 1 To endRow
- '查找下一行
- If Cells(i, 1) = txtjs.Value Then
- curRow = nextRow
- nextRow = i
- Exit For
- End If
- Next i
- Else
- For i = 1 To endRow
- If Cells(i, 1) = txtjs.Value Then
- curRow = i
- nextRow = i
- Exit For
- End If
- Next i
- For i = nextRow + 1 To endRow
- If Cells(i, 1) = txtjs.Value Then
- nextRow = i
- Exit For
- End If
- Next i
- End If
- If i > endRow Then
- '若下一行存在
- If nextRow Then
- txtxs.Value = Cells(nextRow, 2).Value
- MsgBox "已经是最后一行了"
-
- Else
- '下一行不存在,则
- MsgBox "没有找到相关数据"
- End If
- Else
- cmd.Caption = "查找下一个"
- txtxs.Value = Cells(curRow, 2).Value
- End If
- End Sub
- '对数据进行初始化,比如说当前查找到的数据行及下一数据行,还有总的行数
- Private Sub UserForm_Initialize()
- endRow = Range("a65536").End(xlUp).Row
- curRow = 0
- nextRow = 0
- End Sub
-
复制代码
|
|