rowselect = Search.BN.Value 上的类型不匹配存在错误。我想让用户编辑和更新 excel 工作表,excel 工作表被称为"Master"。 错误消息:运行时错误"13"类型不匹配。
Private Sub Update_Click()
Dim Bname As String
Bname = Search.BN.Text
Sheets("MASTER").Select
Dim rowselect As Integer
Dim ans As String
rowselect = Search.BN.Value
rowselect = rowselect + 1
Rows(rowselect).Select
Sheets("MASTER").Cells(rowselect, 6) = Search.A.Text
Sheets("MASTER").Cells(rowselect, 7) = Search.Emailto.Text
Sheets("MASTER").Cells(rowselect, 8) = Search.CClist.Text
Sheets("MASTER").Cells(rowselect, 9) = Search.Emailcc.Text
rowselect = rowselect - 1
Unload Me
ans = MsgBox("S/N " & rowselect & " Successfully Updated...Continue?", vbYesNo, "Update")
If ans = vbYes Then
Search.Show
Else
Sheets("MASTER").Select
End If
End Sub
也许是一个测试,看看是否可以转换并声明为变体以捕获转换时的任何错误。然后测试分支程序是否产生错误。下面仅供说明。
Public Sub TEST()
Dim s As String
'this is illustrative. You would incorporate this so Search.BN.Value was available
s = Search.BN.Value
Dim rowSelect As Variant
On Error Resume Next
rowSelect = CLng(s)
On Error GoTo 0
If IsError(rowSelect) Then Exit Sub
'Your other code......
End Sub