excel - VBA copy paste range into corresponding range for rows with content -
i have spreadsheet called "sicknessrecordgraded" has varying number of rows.
columns - f (1 - 6), have raw content calculate.
columns - ag (9 - 33) there range of formulas calculate information in - f.
preparing vba macro auto copy range of formulas - ag each row there content in - f.
have been attempting write macro follows. have range copy correct using .resize function, have not figured out how paste correct range.
public sub experiment2() dim rw long rw = 3 ' select initial sheet copy sheets("sicknessrecordgraded").select ' find last row of data - xlup check bottom of spreadsheet up. finalrow = cells(rows.count, 1).end(xlup).row ' loop through each row x = 1 finalrow cells(rw, 9).resize(1, 33).copy ' resize intial range. columns - ag. nextrow = cells(rows.count, 1).end(xlup).row + 1 'continue incrementing through rows. cells(nextrow, 1).select ' find next row. activesheet.cells(nextrow, "i").pastespecial xlpasteall ' paste information. sheets("sicknessrecordgraded").select 'reselect sheet copy from. uneccessary. next x end sub
i assume line amend
activesheet.cells(nextrow, 1).pastespecial xlpasteall ' paste information.
to include range function.
if range wish start paste in cells(nextrow, 1)
use:
activesheet.cells(nextrow, 1).pastespecial xlpasteall
or:
activesheet.paste cells(nextrow, 1)
Comments
Post a Comment