Excel VBA Copy and Insert/Paste Special Values from workbooks -
can excel macro? i'm trying copy 1 sheet another, crashes @
sheets("sheet1").range("a6").pastespecial xlpastevalues don't know i'm doing wrong...
sub copy() sheets("sheet1").range("a2:d26").copy workbooks.open("c:\users\j\trial.xltx").activate sheets("sheet1").range("a6").pastespecial xlpastevalues application.cutcopymode = false rngdest.insert xlshiftdown err_execute: if err.number = 0 msgbox "copying successful :)" else _ msgbox err.description end sub also best way around pasting values , inserting data? thanks
try setting parentage objects , working directly them, stayingaway .activate statements. try , make sure trail.xltx workbook has worksheet called sheet1.
sub copy() dim wbthis workbook set wbthis = thisworkbook wbthis.sheets("sheet1").range("a2:d26").copy dim wbpaste workbook set wbpaste = workbooks.open("c:\users\j\trial.xltx") wbpaste.sheets("sheet1").range("a6").pastespecial xlpastevalues rngdest.insert xlshiftdown ' bizarre, because never set variable err_execute: if err.number = 0 msgbox "copying successful :)" else _ msgbox err.description end sub
Comments
Post a Comment