excel - Copying and pasting nonzero rows and adjacent cells -
i dealing lot of gis metadata importing excel, many rows , columns of blank or 0 values. trying take data this:
(left column name, columns right values associated name)
and selecting columns have value, end new set of tables showing nonzero rows , corresponding name left:
i have tried doing filtering data in table shows nonzero values, copying column , far left column , pasting onto new sheet. easy if have few columns, given amount have painstaking. have filter each column separately because rows in each column may or may not have blanks or zeros depending on column.
can lookup function used this, or using vba better?
why can't use 2 simple loops (rows, columns)?? suppose data start "a1", count rows , columns , play code.
sub tras() dim lastrw integer dim lastcol integer dim resultrow integer resultrow = 20 '1th row result lastrw = range("a1").end(xldown).row lastcol = cells(1, activesheet.columns.count).end(xltoleft).column set rgn = range("a1", cells(lastrw, lastrw)) x = 2 lastcol y = 1 lastrw if cells(y, x) <> "" cells(resultrow, 1) = cells(y, 1).value cells(resultrow, 2) = cells(y, x).value resultrow = resultrow + 1 end if next y resultrow = resultrow + 1 next x end sub
Comments
Post a Comment