+ Reply to Thread
Results 1 to 6 of 6

Copying cells from another workbook with VBA

  1. #1
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Copying cells from another workbook with VBA

    Grrr...
    I hate having to ask simple questions which I can't seem to find answers for on account of the fact they're too simple for anyone else to have posted.

    I just need to know how to reference another workbook in order to copy values from cells on it to my own version of it. It's 18 pages, and I need to pull certain columns cell values from certain sheets (these columns are all fixed, no fancy statements required). I'm unfamiliar with the structure required to refer to another workbook. All I need to do is say "This workbook-Sheet1!D2:D20 = Workbook"Feb"-Sheet1!D2:D20", and so on, throughout the sheets.

    I did look for solutions to this, but all of the answers are mixed in with complex statements for other simultaneous calculations... I find myself unable to pick out the small piece which I need from the mash of code I'm unfamiliar with.

    mew.
    Last edited by mewingkitty; 02-17-2009 at 06:00 PM.
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  2. #2
    Registered User
    Join Date
    02-17-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Copying cells from another workbook with VBA

    pasting values:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: Copying cells from another workbook with VBA

    Still getting -
    Runtime error '9'
    Subscript out of range

    with the following code
    Please Login or Register  to view this content.
    trying to copy from the Test from workbook to the Test to workbook, names as seen in attachments.

    This seems far too easy, I'm really clueless as per what I'm missing.
    Attached Files Attached Files

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Copying cells from another workbook with VBA

    Worked for me. Only get the Runtime error '9' when workbook Test from.xlsx was closed

    See link for copying info from a closed workbook
    http://www.rondebruin.nl/ado.htm

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Registered User
    Join Date
    02-17-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: Copying cells from another workbook with VBA

    "subscript out of range" generally means that either "Test from.xlsx" isn't the name of an open workbook, or it doesn't have a "Sheet1"

    or, thisworkbook doesn't have "Sheet1"

  6. #6
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: Copying cells from another workbook with VBA

    Hm, both workbooks are open. I'll check out that link, thanks.

    EDIT:
    Closed them both, opened them again, shebang all's well. Odd, but I'm not going to complain, thanks for the help guys.
    Last edited by mewingkitty; 02-17-2009 at 06:00 PM.

+ 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