excel - How to paste data to specific cell range? -


i'm new vba , need little help. have sheet named "archive" have 12 sets of data displayed/structured in of table format. goal pull data other sheets within same workbook , paste in specific range corresponds appropriate "table" data. here code data being pulled sheet named "daily db" , being pasted "archive" sheet.

sub getdailydatabyweek()  dim cw integer    ' current week dim lr long    'last row of data dim long    ' row counter  'clear exsisting contents worksheets("archive").range("a5:e11").clearcontents  'get week number , year of current date cw = format(date, "ww")  worksheets("daily db")      ' find last row of data     lr = .cells(rows.count, 1).end(xlup).offset(1, 0).row      = 2 lr         if format(.cells(i, 1).value, "ww") = cw             .range(.cells(i, 1), .cells(i, 5)).copy             worksheets("archive").range("a" & rows.count).end(xlup).offset(1,    0).pastespecial xlpasteformulasandnumberformats         end if     next  end  application.cutcopymode = false  end sub 

this code want do. line need in fixing is:

 worksheets("archive").range("a" & rows.count).end(xlup).offset(1,    0).pastespecial xlpasteformulasandnumberformats 

as line looks last row of data, in case header row of 12th table. however, i'd particular data go first table after header row starts @ "a5", i'm not sure how go that. , appreciated.

if want replicate data cell or range same workbook use "value" method of range object, this:

worksheets("archive").range("a" & i).value = worksheets("xxx").range("z" & j).value 

by doing avoid doing copy , paste operations.

if dont want specify range each value, activate firs cell of first row , "offset" way through, this:

worksheets("archive").range("a" & i).activate activecell.value = blah blah blah activecell.offset(1, 0).activate 'if want move next row (same column) activecell.offset(0, 1).activate 'if want move next column (same row) 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -