copying a cell

N

Nestor

does anyone know an easy way to copy a cell in column 1 to column 2
only when the cell in column 2 is blank orempty?

Thank you
Nestor
 
T

Tom Ogilvy

Do alt+F11 and then Insert=>Module
in that module place code like:

sub copytoBlanks()
Dim icol as LOng, cell as Range, rng as Range
icol = 1
set rng = Range(cells(1,icol),cells(rows.count,icol).End(xlup))
for each cell in rng
if isempty(cell.offset(0,1)) then
cell.offset(0,1).Value = cell.value
end if
Next
end sub

Change icol to the column you want to process. As written it processes A
(source column) and B (copy to column) (icol = 1, column to right is B).

go back to Excel, then do Tools=>Macro=>Macros, select CopyToBlanks and
click run
 
Top