Sunday, 15 July 2012

Excel: Writing a macro to move specific columns -



Excel: Writing a macro to move specific columns -

i've tried searching, having problem finding answer. i'm not familiar code , know basic html. found (searching on here, actually) macro find columns titled nil through nil6, , delete them. have piece of macro set (see below).

the part can't find how move specific columns. example, column titled last-name not in same spot. want create move column a. column first-name should move column b... , on. possible? assistance appreciated!

sub deletecolumnbyname() 'find lastly column info in row 1 v = array("nil","nil2","nil3","nil4","nil5","nil6") lastcol = cells(1, columns.count).end(xltoleft).column 'loop through columns, starting @ lastly 1 delcol = lastcol 1 step -1 'delete columns specific name in row 1 bfound = false = lbound(v) ubound(v) if instr(1,cells(1,delcol),v(i),vbtextcompare) bfound = true exit end if next if bfound _ cells(1, delcol).entirecolumn.delete next delcol end sub

excel excel-vba

No comments:

Post a Comment