excel vba - How can I remove columns with red heading in VBA -


i have file red heading, , want delete whole column using vba code? can use loop find red heading , delete column instead of column countrt??

remove space in line if cells(1,icntr). font.colorindex = 3 then between cells(1,icntr). , font.colorindex change columns(icntr).entirecolumn.delete columns(icntr).delete

************* edit ************:
assuming have data/text in headings (first cell of column) macro trick. remember when looping through rows or columns , deleting then, should reverse loop make sure rows or columns checked!

sub deletecolumnswithredheader()  dim ws worksheet dim lcolumn long dim long  'change sheet name!!!!!!!!!!!!! set ws = sheets("your_sheet_name")  'this give last column index data lcolumn = ws.cells(1, columns.count).end(xltoleft).column  'loop through column data - reverse loop check columns = lcolumn 1 step -1      'if first cell in column red delete column     if ws.cells(1, i).interior.colorindex = 3 ws.columns(i).delete  next  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 -