i have created button copies of cells in 1 worksheet new worksheet. want total quantity (h) column of first worksheet go previous quantity(g) column of new worksheet. want current quantity (f) column clear values. each new sheet length of column grow can't set specific range.
activesheet.range("f").clearcontents ??
anything i've done has had copy paste commands , prefer direct method. much!!!
to select entire column in column f, use
activesheet.range("f1").entirecolumn.clearcontents you can extend entirerow, etc.
edit - i'm clear on you're asking.
if have button copies entire worksheet one, assume copies original data well. don't know what's on worksheets, following code should show how copy & paste entire columns.
assume there 2 columns, g , h. first row of g named "previous" , first row of h named "current". following code replaces column g column h while preserving column names in first row:
sub test() 'clear column g: range(cells(2, 7), cells(rows.count, 7)).clearcontents 'copy & paste h g: range(cells(2, 8), cells(rows.count, 8)).copy range("g2").select activesheet.paste 'clear column h: range(cells(2, 8), cells(rows.count, 8)).clearcontents end sub this copy , paste. if have no formulas need preserving, can around code cut , pasting:
sub test() range(cells(2, 8), cells(rows.count, 8)).cut range("g2").select activesheet.paste end sub
Comments
Post a Comment