Problems with the IsNa Function in VB
Is there a reason you don't open the two workbooks in one instance of excel?
NewToVB wrote:
Well LCV and oApp are two different excel applications, i tried to use their
workbooks but it wouldn't let me... for the LCV.worksheetfunction.
Vlookup...I wasn't sure which one to put for "application" so I just used
LCV. Also oApp is from the previous week, LCV is from this week, I'm
searching for the values column A of LCV and see if they exist in column A of
oApp and if it exists return column 10 (J) .... Does that make since? Sorry
if its confusing. But based on that does my code still look right? Thanks
so much for the help!!
"Dave Peterson" wrote:
Typo alert:
If IsEmty(tmp) Then
should be:
If IsEmpty(tmp) Then
=======
To the OP, I don't know what oApp and LCV are either. But are you sure that you
didn't mix them up?
Bob Phillips wrote:
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!
--
Dave Peterson
--
Dave Peterson
|