excel - Copy & Paste range as values into next empty column on another sheet -


using command button, trying copy range (which varies based on inputs) values sheet. have code mentioned below, seems copying on top of last entry rather pasting next empty column. i'm new vba step step appreciated. thank you

sub commandbutton3_click()      dim source worksheet     dim destination worksheet     dim emptycolumn long      set source = sheets("month template")     set destination = sheets("sheet1")      'find empty column (actually cell in row 1)'     emptycolumn = destination.cells(1, destination.columns.count).end(xltoleft).column     if emptycolumn > 1         emptycolumn = emptycolumn + 1     end if      source.range("m26:m35").copy destination.cells(1, emptycolumn)  end sub 

try below

sub commandbutton3_click()     dim source worksheet     dim destination worksheet     dim emptycolumn long     set source = sheets("month template")     set destination = sheets("sheet1")     'find empty column (actually cell in row 1)'     emptycolumn = destination.cells(1, 1).end(xltoright).column     if emptycolumn > 1         emptycolumn = emptycolumn + 1     end if     source.range("m26:m35").copy destination.cells(1, emptycolumn) end sub 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -