Excel VBA - Copying and Pasting from one Workbook to another with a Dynamic Paste Location -
i have 50 excel workbooks same range "sensresultscopy" in same sheet in each of workbooks ("val"). want copy data sheets open workbook. workbook copied dynamic , taken range ("projmodel"), don't know how make paste location dynamic. data each workbook needs go own sheet has named range data needs go, workbook 1's data needs go sheet named "1" , range named "sensrespaste1", workbook 2's data needs go sheet named "2" , range named "sensrespaste1", etc. want make part of vba dynamic using range "activeprojmodel" determine sheet , range "pasterange" range pasted into:
y.sheets("1").range("sensrespaste1")
at moment know how specific sheet , range i.e. in example above, sheet 1. full code below. thanks!
sub datacapture2() application.screenupdating = false application.calculation = xlcalculationmanual application.displayalerts = false dim x workbook dim y workbook dim ws1 worksheet '## open both workbooks first: set y = thisworkbook set x = workbooks.open(range("projmodel")) 'copy x: x.sheets("val").range("sensresultscopy").copy 'paste worksheet in y: y.sheets("1").range("sensrespaste1").pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _ :=false, transpose:=false 'close x: x.close
Comments
Post a Comment