+ Reply to Thread
Results 1 to 5 of 5

Why...

  1. #1
    Registered User
    Join Date
    02-03-2006
    Location
    Canada
    Posts
    18

    Why...

    why is it that for importing data from another spreadsheet this formula works:

    "=[User1.xls]Record!A2"

    But,

    Workbooks("User1.xls").Worksheets("Sheet1").Range("A2")

    ...DOESN'T WORK IN VBA?

    Matts

  2. #2
    Bruno Campanini
    Guest

    Re: Why...

    "mattsvai" <[email protected]> wrote in
    message news:[email protected]...
    >
    > why is it that for importing data from another spreadsheet this formula
    > works:
    >
    > "=[User1.xls]Record!A2"
    >
    > But,
    >
    > Workbooks("User1.xls").Worksheets("Sheet1").Range("A2")
    >
    > ..DOESN'T WORK IN VBA?
    >
    > Matts


    With Workbooks("User1.xls")... User1.xls must be open.
    Is it so?

    Bruno



  3. #3
    Tom Ogilvy
    Guest

    Re: Why...

    Looks like you are using the wrong sheet name

    Workbooks("User1.xls").Worksheets("Record").Range("A2")

    Rather than

    Workbooks("User1.xls").Worksheets("Sheet1").Range("A2")


    if you address the range correctly, it should work. It won't work on a
    closed workbook, however.

    --
    Regards,
    Tom Ogilvy



    "mattsvai" <[email protected]> wrote in
    message news:[email protected]...
    >
    > why is it that for importing data from another spreadsheet this formula
    > works:
    >
    > "=[User1.xls]Record!A2"
    >
    > But,
    >
    > Workbooks("User1.xls").Worksheets("Sheet1").Range("A2")
    >
    > ..DOESN'T WORK IN VBA?
    >
    > Matts
    >
    >
    > --
    > mattsvai
    > ------------------------------------------------------------------------
    > mattsvai's Profile:

    http://www.excelforum.com/member.php...o&userid=31134
    > View this thread: http://www.excelforum.com/showthread...hreadid=508132
    >




  4. #4
    Registered User
    Join Date
    02-03-2006
    Location
    Canada
    Posts
    18
    actually "Record" and "Sheet1" was used for hypothetical situation and not a mistake.. thanks for pointing it out though.

    I found out from Toms post in another thread that the workbook() function cannot include paths of closed workbooks in VBA... so I guess its a NO GO.

  5. #5
    Tom Ogilvy
    Guest

    Re: Why...

    Tom and other's also suggested some other approachs.

    Here is another one although this would be slower.

    http://www.j-walk.com/ss/excel/tips/tip82.htm
    A VBA Function to Get a Value From a Closed File


    --
    Regards,
    Tom Ogilvy



    "mattsvai" <[email protected]> wrote in
    message news:[email protected]...
    >
    > actually "Record" and "Sheet1" was used for hypothetical situation and
    > not a mistake.. thanks for pointing it out though.
    >
    > I found out from Toms post in another thread that the workbook()
    > function cannot include paths of closed workbooks in VBA... so I guess
    > its a NO GO.
    >
    >
    > --
    > mattsvai
    > ------------------------------------------------------------------------
    > mattsvai's Profile:

    http://www.excelforum.com/member.php...o&userid=31134
    > View this thread: http://www.excelforum.com/showthread...hreadid=508132
    >




+ 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