用VB写了一个查询窗体,然后需要查询的内容在表格中没有就跳了对象变量或whit块变量未设置
以下是问题代码
private sub commandbutton1_click()
Me.textbox1.value = range("A:A").find(me.textbox1.value).offset(0,1)
End sub
Private Sub CommandButton1_Click()
Dim foundRange As Range
Set foundRange = Range("A:A").Find(Me.TextBox1.Value)
If Not foundRange Is Nothing Then
Me.TextBox1.Value = foundRange.Offset(0, 1).Value
Else
MsgBox "未找到匹配项"
End If
End Sub