excel - Paste cells in specific row based on column header -


i not programmer appreciate help!

i trying take range of cells, , paste them in part of spread sheet in correct column want (the column change later that's why want identify column paste cells right row)

example, take cells (a2:a10) , paste them "ttm" column d4:d12... have put text ttm d1... later, ttm may become e1, in case a2:a10 cells need moved e4:e12...

thanks lot!

the following function can used want. need explain trigger code , if want search other 'active sheet'

function move_cells() dim icols   integer dim       integer dim strkey  string dim inewcol integer      strkey = "ttm"      ' set whatever label want search row 1 for.     icols = activesheet.usedrange.columns.count         ' count of used columns      = 1 icols              ' find column containing 'ttm'         if lcase(cells(1, i).text) = lcase(strkey)     ' ignore case incase somebody....             inewcol =             ' save col # containing search keyword             exit         end if     next      'activesheet.range("a2:a10").copy        ' copy     'activesheet.cells(2, inewcol).pastespecial xlpastevalues        ' paste new location     'application.cutcopymode = false      ' try following instead of previous copy/paste     range("a2:a10").select     selection.copy     cells(2, inewcol).select     activesheet.paste  end function 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -