View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Problems with the IsNa Function in VB

Not tested as I have no idea what LCV or oAPp is, but you could try this

Dim tmp As Variant

For i = 3 To LastRow Step 1

On Error Resume Next
tmp = LCV.WorksheetFunction.VLookup(LCV.Range("A" & i).Value, _
oApp.Range("A1:J" & LastRow).Value, 10, False)
On Error GoTo 0

If IsEmty(tmp) Then
LCV.Range("L" & i).Value = 0
Else
LCV.Range("L" & i).Value = tmp
End If
Next i



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"NewToVB" wrote in message
...
I'm using visual studio to work with excel, Can anyone tell me why this
isn't
working:

For i = 3 To lastRow Step 1

If
(LCV.WorksheetFunction.IsNA(LCV.WorksheetFunction. VLookup(LCV.Range("A" &
i).Value, oApp.Range("A1:J" & lastRow).Value, 10, False))) Then
LCV.Range("L" & i).Value = 0
Else : LCV.Range("L" & i).Value =
LCV.WorksheetFunction.VLookup(LCV.Range("A" & i).Value, oApp.Range("A1:J"
&
lastRow).Value, 10, False)
End If

Instead of returning a zero where there is an N/A it just kicks me out of
the program. Any ideas? Thanks ahead of time!