ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   copying a cell (https://www.excelbanter.com/excel-discussion-misc-queries/86164-copying-cell.html)

Nestor

copying a cell
 
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


Tom Ogilvy

copying a cell
 
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(xlu p))
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



--
Regards,
Tom Ogilvy


"Nestor" wrote:

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



Nestor

copying a cell
 
Thank you - this also worked:

=IF(ISBLANK(B3),A3,B3)



All times are GMT +1. The time now is 04:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com