Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using Vlookup to add values to a spreadsheet


Hi,

I'm attempting to use vlookup to determine whether a value in one
spreadsheet (S1) is in another (S2), so that I can add that value to S2
if it isn't there. I'm checking all the values in S1 with a Do
While...Loop statement. I've coded so that OnError for the VLookUp, it
goes to the code that adds the value. This works perfectly for the
first value that cannot be found in S2, but for the second I get a
run-time 1004 error - 'Unable to get the Vlookup property of the
WorksheetFunction class'. I think that Excel is having a problem
dealing with an error when one is, effectively, still 'open', so to
speak. Can anyone help at all? This is driving me mad!

Regards,

MasterGee


--
MasterGee
------------------------------------------------------------------------
MasterGee's Profile: http://www.excelforum.com/member.php...o&userid=26372
View this thread: http://www.excelforum.com/showthread...hreadid=396462

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Using Vlookup to add values to a spreadsheet

What is in your OnError code? Are you using the Resume keyword anywhere or
Err.Clear?
--

Simon


"MasterGee" wrote:


Hi,

I'm attempting to use vlookup to determine whether a value in one
spreadsheet (S1) is in another (S2), so that I can add that value to S2
if it isn't there. I'm checking all the values in S1 with a Do
While...Loop statement. I've coded so that OnError for the VLookUp, it
goes to the code that adds the value. This works perfectly for the
first value that cannot be found in S2, but for the second I get a
run-time 1004 error - 'Unable to get the Vlookup property of the
WorksheetFunction class'. I think that Excel is having a problem
dealing with an error when one is, effectively, still 'open', so to
speak. Can anyone help at all? This is driving me mad!

Regards,

MasterGee


--
MasterGee
------------------------------------------------------------------------
MasterGee's Profile: http://www.excelforum.com/member.php...o&userid=26372
View this thread: http://www.excelforum.com/showthread...hreadid=396462


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Using Vlookup to add values to a spreadsheet

Having thought some more about this, I think I had the same problems and so
used the FIND method instead. This either returns a Range object variable or
Nothing.
--

Simon


"Simon Letten" wrote:

What is in your OnError code? Are you using the Resume keyword anywhere or
Err.Clear?
--

Simon


"MasterGee" wrote:


Hi,

I'm attempting to use vlookup to determine whether a value in one
spreadsheet (S1) is in another (S2), so that I can add that value to S2
if it isn't there. I'm checking all the values in S1 with a Do
While...Loop statement. I've coded so that OnError for the VLookUp, it
goes to the code that adds the value. This works perfectly for the
first value that cannot be found in S2, but for the second I get a
run-time 1004 error - 'Unable to get the Vlookup property of the
WorksheetFunction class'. I think that Excel is having a problem
dealing with an error when one is, effectively, still 'open', so to
speak. Can anyone help at all? This is driving me mad!

Regards,

MasterGee


--
MasterGee
------------------------------------------------------------------------
MasterGee's Profile: http://www.excelforum.com/member.php...o&userid=26372
View this thread: http://www.excelforum.com/showthread...hreadid=396462


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using Vlookup to add values to a spreadsheet


Hi Simon,

Firstly, many thanks for your reply.

My OnError code just adds the value in the first spreadsheet to th
second spreadsheet - there's no Err.Clear or Resume in there, as I'
not aware of these statements/Keywords. I'll certainly give them ag
though, as that sounds like the kind of solution I was expecting.

Never thought about using Find, as, if I do find the value, I have t
return an associated value from the second spreadsheet to the first
hence the Vlookup. However, if Err.Clear or Resume doesn't work, I'l
give that a go.

Once again, thanks ever so much. :

--
MasterGe
-----------------------------------------------------------------------
MasterGee's Profile: http://www.excelforum.com/member.php...fo&userid=2637
View this thread: http://www.excelforum.com/showthread.php?threadid=39646

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Vlookup to add values to a spreadsheet

I'd guess you didn't reset your error handling code correctly, too.

dim Res as variant
on error resume next
res = application.worksheetfunction.vlookup(----)
if err.number < 0 then
res = "Missing???"
err.clear
end if
on error goto 0

=========

But you can drop the .worksheetfunction portion and just check for an error:

dim res as variant
res = application.vlookup(....)
if iserror(res) then
res = "missing???"
end if

I find the application.vlookup() much easier to work with and easier to
understand.




MasterGee wrote:

Hi Simon,

Firstly, many thanks for your reply.

My OnError code just adds the value in the first spreadsheet to the
second spreadsheet - there's no Err.Clear or Resume in there, as I'm
not aware of these statements/Keywords. I'll certainly give them ago
though, as that sounds like the kind of solution I was expecting.

Never thought about using Find, as, if I do find the value, I have to
return an associated value from the second spreadsheet to the first -
hence the Vlookup. However, if Err.Clear or Resume doesn't work, I'll
give that a go.

Once again, thanks ever so much. :)

--
MasterGee
------------------------------------------------------------------------
MasterGee's Profile: http://www.excelforum.com/member.php...o&userid=26372
View this thread: http://www.excelforum.com/showthread...hreadid=396462


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VLookup multiple values - sum returned values into single cell se7098 Excel Worksheet Functions 12 April 2nd 23 07:32 PM
VLookup: Get a value from a different spreadsheet Simon Excel Worksheet Functions 3 March 24th 08 10:04 PM
How do I match values in one spreadsheet to values in another? David Excel Worksheet Functions 2 August 15th 06 03:30 PM
Can Vlookup from one spreadsheet and not another Melinda Excel Worksheet Functions 2 January 25th 06 09:41 PM
vlookup, multiple values, sum values into one cell?? Phillips L Excel Worksheet Functions 4 November 9th 05 12:31 AM


All times are GMT +1. The time now is 10:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"