+ Reply to Thread
Results 1 to 8 of 8

Vlookup with VBA

  1. #1
    Registered User
    Join Date
    09-07-2007
    Posts
    5

    Vlookup with VBA

    Hi All,

    I'm trying to find out a way to solve this problem:

    I have an external password-protect xls file in which there is the second worksheet that contains a list of elements like the following one:

    Column A Column B
    10-Sep-2007 10am-19am
    11-Sep-2007 10am-19am
    12-Sep-2007 09am-18-am

    I need to locate a specific cell in the Column B depending on the actual day and paste the content into my Excel Sheet.

    I was able to open the external file, but I was only able to retrieve the content of a specified cell.

    This is the code I'm using:
    Please Login or Register  to view this content.
    Anyone can suggest me how to correct that Vlookup function?????

    Any help will be really appreciated!!!

    Thank you,
    Steve
    Last edited by VBA Noob; 09-18-2007 at 10:24 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I wouldn't use VLOOKUP, but use the .Find method. I'm not sure exactly what you want to do, attach an example workbook.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-07-2007
    Posts
    5

    Example

    Thank you RoyUK for your reply!

    I'll try to better explain what I'm trying to do with a couple of screenshots:

    Let's say that I want to display in the cell B4 (attachment "file1.jpg") the exact copy of the content of the cells on the B column on the second attachment (file2.jpg - external file) depending on the day.

    So, if today were 17/09/2007 I would like to have in B4 the value 10-7pm

    Possibly not important, but please note that the date's values are in the format d/m/yyyy

    What I'm receiving is just #N/A

    Do you think that .find is the solution?


    Thank you very much!
    Steve
    Attached Images Attached Images

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I can help you better if you attach a workbook example.

  5. #5
    Registered User
    Join Date
    09-07-2007
    Posts
    5

    'Real' Example

    Hi RoyUK!

    You are right, I'm attaching two examples (basically these are the worksheets I'm using, just without most of the data to make them smaller)...

    Basically, the file "shifts.xls" will have to find and read info from calendar.xls using vlookup...

    Calendar.xls is a password protected file, and the pwd is "test"...

    RoyUK, thank you for your help!!!
    Steve

  6. #6
    Registered User
    Join Date
    09-07-2007
    Posts
    5

    Attachments

    Ooops...

    here you have the attachments...

    :-)
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    See if this helps

    Please Login or Register  to view this content.

    rylo

  8. #8
    Registered User
    Join Date
    09-07-2007
    Posts
    5

    No way...

    Hi RoyUK,

    I've tested your code, but it will report "subscript out of range"...

    I was thinking that maybe is related to the cell format of the calendar.xls file, and I've tried to change it with no success at all...

    Do you have any other idea???

    Anyway... many thanks for your help and your time!!!


    Stefano

+ 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