Copy Values Only From One Workbook To Another

  • I'm trying to copy values only from a specified range on one workbook to another.


    Example:


    Copy the values only (not the formulas or formatting) from cells C479:Y529 on "sheet 1" of "workbook A"


    to Cell A1 on "sheet 1" of "workbook B".


    Any help would be appreciated.

  • Re: Copy Values Only Of A Specified Range From One Workbook To Another


    You should try searching links at the bottom first for an answer


    Try something like


    Code
    Workbooks("WorkbookA.xls").Sheets("Sheet1").Range("C479:Y529").Copy
    Workbooks("WorkbookB.xls").Sheets("Sheet1").Range("A1").PasteSpecial Paste:=xlPasteValues


    VBA Noob

  • Re: Copy Values Only Of A Specified Range From One Workbook To Another


    I typed the following into the Visual Basic Editor


    Code
    Sub ACD_Week_1()
    
    
    Workbooks("drc_mtd_tx200804.xls").Sheets("APR").Range("C479:Y529").Copy
    Workbooks("template.xls").Sheets("ACD").Range("A1").PasteSpecial Paste:=xlPasteValues
    
    
    End Sub


    It gives me a runtime error '9' 'subscript out of range' and when I click debug it highlights this row


    Code
    Workbooks("drc_mtd_tx200804.xls").Sheets("APR").Range("C479:Y529").Copy


    Sorry to be such a noob at all this. I've read other threads and I understand what the code is saying, I'm just not sure how to format it in the VB editor properly.


    I have both workbooks open and ready to go and they're all named properly.

  • Re: Copy Values Only Of A Specified Range From One Workbook To Another


    You don't have a rogue space in sheet tab


    Try running the actions and see what code is output


    VBA Noob

  • Re: Copy Values Only Of A Specified Range From One Workbook To Another


    If I try to record the actions this is the code it generates



    It's as if it's not talking to the other workbook. Is there something I have to enable in excel to allow this workbook to access other workbooks?[hr]*[/hr] Auto Merged Post Until 24 Hrs Passes;[dl]*[/dl]I figured it out.


    I was opening two separate instances of excel and opening each workbook. I used the same excel window to open up the second workbook and it's working now.


    Thanks for all the help. Hopefully this thread will be helpful to others as well.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!