excel - Copy active cell row and insert copied row directly underneath -
i trying copy active cell row , want insert copied row directly beneath row. so:
row 1 < user clicks relevant cell trigger macro (active row) row 2 < copied cell gets inserted directly beneath active row
i want happen if there row below active row i.e. this, when user clicks copy active row:
row 1 < active row row 2 < other content
would turn this:
row 1 < active row row 2 < copied cell gets inserted directly beneath active row row 3 < other content
here code have tried put no luck:
'add tender type row dim nextrow range set nextrow = range("b" & sheets("home").activecell.rows.count + 1) if not intersect(target, range("af" & activecell.row)) nothing , range("af" & activecell.row).value = "+" sheet1.range("b" & activecell.row & ":af" & activecell.row).copy sheet1.activate nextrow.pastespecial paste:=1, operation:=xlnone, skipblanks:=false, transpose:=false application.cutcopymode = false end if
please can show me correct way this?
you definition of nextrow
wrong, used sheets("home").activecell.rows.count + 1
instead of activecell.row + 1
give try :
sub mark_harris() dim ws worksheet, _ nextrow range if target.cells.count > 1 exit sub set ws = activeworkbook.sheets("home") ws if not intersect(target, .range("af" & activecell.row)) nothing , .range("af" & activecell.row).value = "+" .rows(activecell.row + 1).insert shift:=xldown set nextrow = .range("b" & activecell.row + 1) .range("b" & activecell.row & ":af" & activecell.row).copy nextrow.pastespecial paste:=1, operation:=xlnone, skipblanks:=false, transpose:=false end if end application.cutcopymode = false end sub
Comments
Post a Comment