Type Mismatch, Run Time error 13
I am getting a type mismatch error for the below at the if iRowValue null check
what i am trying to do is to determine if the value already exists in the sheet then update that column or else append at the end.
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 is declared as Long, you then try to compare it to a String - which can't work. Simply compare against 0 and it should work.
精彩评论