[英]Type Mismatch, Run Time error 13
我在 if iRowValue null 檢查中收到以下類型不匹配錯誤
我要做的是確定工作表中是否已經存在該值,然后更新該列,否則最后更新 append。
Public iRowValue As Long
Public iRow As Long
----------
Private Sub Update_Click()
Dim Rng As Range
Dim FindString1 as String
With ws.Range("A:A")
Set Rng = .Find(What:=FindString1, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Rng Is Nothing Then
MsgBox "Name does not Exists"
Else
iRowValue = Rng.Row
End If
End With
**If iRowValue <> "" Then**
iRow = iRowValue
Else
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
End If
ws.Cells(iRow, 1).Value = Me.FirstName.Value
ws.Cells(iRow, 2).Value = Me.LastCode.Value
End Sub
iRowValue 被聲明為 Long,然后您嘗試將其與 String 進行比較——這是行不通的。 只需與 0 進行比較,它應該可以工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.