excel vba - Copy and Paste to next available column -


i'm trying track weekly quantities have in spread sheet. far i've made macro copy , paste info need it. paste spot chose while recording macro. i'd paste info next available column.

i'd schedule macro run once week on friday morning.

macro i'm using now.

sub copypaste() ' ' copypaste macro '  '    range("g4:g33").select    selection.copy    range("b35").select    selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _     :=false, transpose:=false end sub 

i've tried putting & lastrow range, gets compile error. appreciated.

you can work out column number of last column this:

sub copypaste() ' ' copypaste macro ' dim lastcol long ' finds number of last column lastcol = cells(35, columns.count).end(xltoleft).column     range("g4:g33").copy  '   range("b35").select ' no need select. paste cell in row 35, 1 right of last column    cells(35, lastcol + 1).pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _     :=false, transpose:=false end sub 

you add 1 right in lastcol definition, like

   lastcol = cells(35, columns.count).end(xltoleft).column + 1    range("g4:g33").copy    cells(35, lastcol).pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks _       :=false, transpose:=false 

for scheduling macro @ these 2 questions here , here


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -