我需要你的帮助我在使用Do until
时非常困惑,我们有一个项目添加,搜索,编辑和删除。
我无法完成搜索,因为它无法正常工作,无限循环。
示例我需要使用inputbox在范围(" A")上搜索相同的字符串 我使用UCase作为我的默认设置
Dim find As Integer
Dim search As String
search = inputbox ("Input the String")
search1 = UCase(search)
find = 1
Do until not Cells(find,1).value = ""
If search1 = Cells(find,1).value then
MsgBox "The Item was Found"
Else
find = find + 1
MsgBox "The Item was Not Found or No Record"
End If
Loop
确切的输出是 如果陈述是真的= MsgBox"物品被发现" 如果假= MsgBox"项目未找到或没有记录" 结束循环
编辑 - 您将输入一个字符串,用于"您要更改的项目"和"您要更新的项目"之后如果为true则进行匹配过程,如果为false,则范围的值将更改,没有项目记录(程序结束)
删除 - 搜索相同的范围值并删除整个单元格
使用循环我可以理解的任何简单程序:(
这是新代码:
Private Sub CommandButton2_Click()
Dim find As String
Dim findscan As Integer
findscan = 3
find = InputBox("Input The Name or Serial Number")
findu = UCase(find)
Do Until Not Cells(findscan, 2).Value <> ""
If findu = Cells(findscan, 2).Value Then
MsgBox "The Item was Found", vbInformation, "Sucess"
Exit Do
Else
findscan = findscan + 1
MsgBox "The Item was Not Found", vbCritical, "Error"
End If
Loop
End Sub