excel - Copying values across a dynamic column and row range -
i have following code that:
- copies column headings (in row 1) column c across second last column
- pastes these column headings in row 1 in column 2 across last column data
pastes column headings alongside each row of data through bottom row
sub gldr() 'use end(xlup) determine last row data, in column of gldryypp tab dim lastrowdr long lastrowdr = sheets("gldryypp").range("a" & rows.count).end(xlup).row 'copy cost type categories , paste alongside cost centres ctnamecol = "s2:af" & lastrowdr sheets("gldryypp").range("c1", range("c1").end(xltoright).offset(0, -1)).copy sheets("gldryypp").paste destination:=sheets("gldryypp").range("c1").end(xltoright).offset(0, 2) sheets("gldryypp").range(range("c1").end(xltoright).offset(0, 2), range("c1").end(xltoright).offset(0, 2).end(xltoright)).copy sheets("gldryypp").paste destination:=sheets("gldryypp").range(ctnamecol) end sub
the first 2 steps have been set dynamic additional columns added having trouble writing code paste data through bottom row. can see range "s2:af(last row)" has been written make use of result lastrowdr dimension.
is there way write code make copy dynamic across columns , rows?
yes there way write code make copy dynamic across columns , rows. need identify distinct quality cost centres locate using activesheet.cells.find(txt)
. you'll able determine ctnamecol should be. there helpful info here: range.find method.
if add add picture of spreadsheet update answer more precise information.
Comments
Post a Comment