Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vlookup 400 error

Status
Not open for further replies.

bluedragon2

IS-IT--Management
Jan 24, 2003
2,642
US
Can anyone explain the errors of my ways :)

I am getting a 400 error when the vlookup does not find a match:

a = 0
t = 1
For i = 10 To 110

z = WorksheetFunction.VLookup(Cells(i, 1).Value, Range("B1:B63"), 1, 0)
On Error GoTo 0
If z = 0 Then
a = i - 9
Else
Cells(t, 3).Value = a
r = 1
For x = 4 To 10
Cells(t, x).Value = Cells(r, 1).Value
r = r + 1
Next x
t = t + 1
Exit Sub
End If
Next i

Thanks



[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
One little change in there:

a = 0
t = 1
For i = 10 To 110

z = WorksheetFunction.VLookup(Cells(i, 1).Value, Range("B1:B63"), 1, 0)
On Error GoTo 0
If z > 0 Then
a = i - 9
Else
Cells(t, 3).Value = a
r = 1
For x = 4 To 10
Cells(t, x).Value = Cells(r, 1).Value
r = r + 1
Next x
t = t + 1
Exit Sub
End If
Next i


[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
Actually, I found a way around it.

Thanks though



[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top