Handling Errors from Worksheet Functions

  • Thread starter Thread starter Nigel
  • Start date Start date
N

Nigel

I have some code (snippet below) that seek to lookup a value (iuser) from a
Range (USERS), the function works fine until it encounters the #N/A return
value caused by iuser not being in the USERS array. How do I handle this
correctly?

What I am seeking to do is put the invalid iuser value into a worksheet
cell.

'<code snippet>
ibarea = Application.WorksheetFunction.VLookup(iuser, Range("USERS"), 2, 0)
 
Range("xx") is the cell of your choice:

Sub Tester
On Error Resume Next
ibarea = Application.WorksheetFunction. _
VLookup(iuser, Range("USERS"), 2, 0)
If Err <> 0 Then Range("xx") = ibarea
On Error GoTo 0
End Sub

HTH,
Shockley


Nigel said:
I have some code (snippet below) that seek to lookup a value (iuser) from a
Range (USERS), the function works fine until it encounters the #N/A return
value caused by iuser not being in the USERS array. How do I handle this
correctly?

What I am seeking to do is put the invalid iuser value into a worksheet
cell.

'<code snippet>
ibarea = Application.WorksheetFunction.VLookup(iuser, Range("USERS"), 2, 0)




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

webservice 1
Is that a good design? 5
Vlookup Error 0
Operator Overloading 1
UDF not working for VLookup 6
Vlookup with multiple FOR condition 1
Connectiing to SQL 2005 from ASP Pages 5
Login program failure 7

Back
Top