excel vba - copying selected data from one workbook to another with readdressing cells -
guys need funky vba commands. have 2 spreadsheets, first labownik-mil-2dl8.xls , second zestawienie.xls , want select rows in first 1 copy second 1 not a1 a1. if selection rows 5270 5273 want example e5272 d7 , ak5272 e7 , on. nice if done button press in second spreadsheet (firstly making selection in first spreadsheet). makro should paste first empty row in second spreadsheet. have this:
sub get_data() dim lastrowdb long, lastrow long dim arr1, arr2, integer sheets("zestawienie") lastrowdb = .cells(.rows.count, "d").end(xlup).row + 1 end arr1 = array("e", "ak", "b", "d", "f", "g", "h") arr2 = array("d", "e", "f", "h", "l", "m", "n") = lbound(arr1) ubound(arr1) sheets("labownik") lastrow = application.max(3, .cells(.rows.count, arr1(i)).end(xlup).row) .range(.cells(3, arr1(i)), .cells(lastrow, arr1(i))).copy sheets("zestawienie").range(arr2(i) & lastrowdb).pastespecial xlpastevalues end next application.cutcopymode = false end sub
but working when both sheets in 1 file, , makro copying whole data not selection. have no idea how properly.
sorry if hard read english not native language.
thank in advance
you have add workbook object know how work both workbooks. code treating them worksheets in same workbook.
dim wbsecond workbook set wbsecond = workbook.open(parameters)
that allow reference 1 workbook @ wbsecond , can reference workbook you're in myworkbook.
then can use syntax:
myworkbook.sheets(sheet_name).cells(row,col) = wbsecond.sheets(sheet_name).cells(row, col)
Comments
Post a Comment