excel - If statement to copy cells if they are NOT blank else, don't copy -


i wanna ask how should write if statement copy , paste data on range of cells if not empty, , if range of cells empty, should not copy anything.

any suggestion appreciated. thanks!

this copies cell values column 1 (usedrange) column 2 if cell not empty:


option explicit  public sub copyifnotempty()      dim cel range, lrow long      'next line determines last row in column 1 (a), of first worksheet     lrow = worksheets(1).usedrange.columns(1).rows.count      'iterate on every cell in usedrange of column     each cel in worksheets(1).range("a1:a" & lrow)          'cel represents current cell         'being processed in iteration of loop          'len() determines number of characters in cell         if len(cel.value2) > 0              'if cel not empty, copy value cell next              'cel.offset(0, 1): cell offset current cell             ' - 0 rows current cell's row (1 row below, -1 row above)             ' - 1 column right of current cell's column (-1 column left)              cel.offset(0, 1).value2 = cel.value2          end if      next    'move on next (lower) cell in column 1  end sub 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -