excel - Copying rows from one sheet to another -


the following script seems should work, i'm getting "object defined" error on lines marked below. can't find what's causing @ all...

sub mailmerge() sheets.add.name = "mailmerge" dim mailmerge worksheet set mailmerge = sheets("mailmerge") dim rng range dim i, index, lastrow long dim abstracts worksheet set abstracts = sheets("abstracts")  lastrow = abstracts.cells(rows.count, 1).end(xlup).row   = 1 lastrow     set rng = abstracts.range("o" & i)         if worksheetfunction.counta(rng) >= 1             abstracts.range("a" & i).resize(0, 14).copy _             destination:=mailmerge.range("a" & i).resize(0, 14)             'this error occuring          end if next  end sub 

any suggestions?

resize not offset. set size of range size dictated. setting range size 0 rows. should 1:

sub mailmerge() sheets.add.name = "mailmerge" dim mailmerge worksheet set mailmerge = sheets("mailmerge") dim rng range dim i, index, lastrow long dim abstracts worksheet set abstracts = sheets("abstracts")  lastrow = abstracts.cells(rows.count, 1).end(xlup).row   = 1 lastrow     set rng = abstracts.range("o" & i)         if worksheetfunction.counta(rng) >= 1             abstracts.range("a" & i).resize(1, 14).copy _             destination:=mailmerge.range("a" & i).resize(1, 14)             'this error occuring          end if next  end sub 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -