+ Reply to Thread
Results 1 to 25 of 25

Unable to get the VLookup property of the WorksheetFunction class

  1. #1
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Unable to get the VLookup property of the WorksheetFunction class

    Hi!

    So... I am trying to look at column at of two different workBOOKS and then when a match is found take the value from column D in workbook two and copy it to the corresponding row in the current column of workbook one.

    this is the code I'm using and I get that unable to get the vlookup function. blah blah blah... so at first I thought maybe it was because not all of them will have matches so it could return an error if it is trying to return empty, so I put int on error resume next, and it ran through but never brought over ANY data, and there ARE matches and data to be brought over.

    Anywho... here is the affected portion of my macro. Thanks for any help.

    destRng is the range in the current column(that i just inserted) on the active worksheet that we will be putting the new info into.
    srcRng is the range in column A on the other workbook that the numbers are being compared to.
    src is just an integer

    Please Login or Register  to view this content.
    Again thanks for any help.
    Last edited by JesseBurton; 12-04-2009 at 04:04 PM.

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    Re: Unable to get the VLookup property of the WorksheetFunction class error???

    Maybe:

    Please Login or Register  to view this content.
    HTH,
    Jason

  3. #3
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class error???

    Thanks, but no Joy.

    Also. I am pretty new to this, so I just wanted to know, I don't have to set the range variable rCell to anything before I use it in this process? I had seen it other places never being set to anything before being used like this, which confuses me a little.
    Last edited by JesseBurton; 12-04-2009 at 04:06 PM.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Unable to get the VLookup property of the WorksheetFunction class

    A couple of observations:
    1. Dim rCell As Variant
    2. Dim src as Long

    Ben Van Johnson

  5. #5
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Is srcRng at least 4 columns wide?

    Also, what is ("A" & src) referring to?

  6. #6
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Thanks, I changed rCell to Varient, and yea i had src as Long dont know why I said int before.

    Still no joy though.


  7. #7
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    yes srcRng is currently A1:D10

    ("A" & src) is a cell reference src is a long variable that is counting up so that it will check each cell.

  8. #8
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Ok, then you definitely need to use:

    Please Login or Register  to view this content.
    As I suggested above. I think you also need to fully qualify the range, something like:

    Please Login or Register  to view this content.
    Or

    Please Login or Register  to view this content.
    Try it out.

    Oh, and since you are using srcRng solely as a Range variable, then it is fine to declare as a Range than Variant.

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Unable to get the VLookup property of the WorksheetFunction class

    You said:
    destRng is the range in the current column...
    Show the code that sets destRng

  10. #10
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Unhappy Re: Unable to get the VLookup property of the WorksheetFunction class

    THANK YOU SOOOO MUCH!!!

    but now I get the error Object doesn't support this property or method.

  11. #11
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Can you post what your code is at this point?

  12. #12
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Quote Originally Posted by protonLeah View Post
    You said:

    Show the code that sets destRng


    here it is

    Please Login or Register  to view this content.
    I know the destination range is right because I have had the formulas paste into those cells just not the values.

  13. #13
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Quote Originally Posted by jasoncw View Post
    Can you post what your code is at this point?
    Ok but um, just to warn you, it does alot more than just this part, and it's really ugly. this is the first time I have ever done any kind of programming ever and have been teaching myself as I go.... so I'm sorry.

    Please Login or Register  to view this content.

    So you can essentially ignore most of the code the problems are just the last little bit of it. (Oh and I tried it as both a Range and Variant and got the same error)

  14. #14
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Hahahaa, yea it's a mess I know, no one wants to touch it with a 10 ft pole now. hahahaha

  15. #15
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Don't be embarrassed about learning. Showing what you are doing will only help you here.

    Some questions I have regarding the code:

    1. From which workbook should srcRng come? I think you need to change this line of code:

    Please Login or Register  to view this content.
    2. From which workbook should NumofRows come? I think you need to change this line of code:

    Please Login or Register  to view this content.
    3. I think you can get rid of the Do Loop. Actually, delete from the Do Loop to the end, and replace it with (assuming I have the correct workbooks listed):

    Please Login or Register  to view this content.
    Hopefully that helps. It's hard to tell without actually seeing the workbook. Be sure to post back.

  16. #16
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    The first two I have the correct workbooks listed. src is source and dest is destination. The destination will have 86 rows and the source each time will have fewer rows than that, up to 85 but realistically never even close to that many.


    I am gonna check out the other code you have there now. I am hesitant to take anything out that is currently working... hahaha

    What I have going on now is that i get raw data from an id swiper as a csv file then i compare the swipe data and match them up deleting the duplicates that are within a few minutes of each other (like the werent sure if it registered or not) and then calculating how long they were there and rounding it to the quarter of an hour.

    Now I am opening the master list of students hours, and trying to get it to compare that day's list of hours with the master list and insert a new row to put that day's hours in when it finds matching student id numbers. I'm just not able to get it to compare and insert the data.

  17. #17
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    So I just took out everything from the do loop and put in your code but at the set cell line it game me the application-defined or object-defined error message.

    I dont really understand everything that is going on in your code with Cell. I want the destRng to be only the column that I had just inserted and only as many rows as there are student numbers in.

  18. #18
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Unable to get the VLookup property of the WorksheetFunction class

    I'm hoping to see a sample WB...

  19. #19
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Quote Originally Posted by protonLeah View Post
    I'm hoping to see a sample WB...
    Ok so I have attached a raw data set from the swiper, and I have attached a cleaned version (I took out all the personal information and all but the last few columns of manually entered data) of the master spreadsheet. The the raw data actually comes in a csv file, but I had to convert it to upload it.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Here is another file, it is the spreadsheet, of the raw data after it has been treated with the first part of the macro, so I guess it is a spreadsheet of the treated data. This is the spreadsheet format that I am trying to compare to the master list spreadsheet I uploaded before to insert the new column in the master and then insert the total hours from column D in the treated data to the corresponding rows in the new column in the master spreadsheet.

    I hope this helps.

    And THANK YOU AGAIN FOR ALL THE HELP! I SINCERELY APPRECIATE IT!!!

  21. #21
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Unhappy Re: Unable to get the VLookup property of the WorksheetFunction class

    So I guess it's just not possible?

  22. #22
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Unable to get the VLookup property of the WorksheetFunction class

    My best guess from what you've posted is something like this for the last part:

    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  23. #23
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    Thanks,

    This is getting really close, and I've been playing with it trying to get it to work. The problem I'm running into is that it doesn't seem to actually be running the lookup for each cell in the master list, it is only running it on the first however many rows I have in the source data from that day. So if I have 10 rows of data it will only check the first 10 rows of the master list for matches. It doesn't look like it should be doing this, but it is. Any ideas?

  24. #24
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Unable to get the VLookup property of the WorksheetFunction class

    It should be doing it for each row in the Hours sheet. Is that not the case, or is that what it is doing, but that is not what you want? (Neither workbook you posted had any code in it, so I had to take a guess as to what was controlling what)

  25. #25
    Registered User
    Join Date
    12-04-2009
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Unable to get the VLookup property of the WorksheetFunction class

    UGH I'm such a retard, yea the macro is stored in a third workbook. (sorry about that, here is that workbook) It is not in the same state that it was in when I had posted earlier, I have been playing with different ways of trying to get this to work. I will also post a .txt file with all the code snippets I've been cutting and pasting in and out of this end part of my code.
    Last edited by JesseBurton; 12-09-2009 at 10:35 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1