Special copying of columns

K

KaZetE

Hi,

I need your help again :-(

I have two columns A and B.
In column A there are values of general type,
in fact there are strings of characters.
In column B there are values of general type
or fields are empty.
The values in columnB can be equal to those
in columnA or can be different.
What I need is to copy values from columnA
to columnB but only if the field in columnB
was empty.

For example:
ColumnA ColumnB
qwe tyf
fgyed
jdge jdge
ifresg plk
sgdhey
utshr utshr
etc.

The result should be:
ColumnA ColumnB
qwe tyf
fgyed fgyed
jdge jdge
ifresg plk
sgd sgd
utshr utshr
etc.

Of course the sheet contains hundreds of records
so it would be terrible to do it handy.

If anyone knows how to do it, please tell me.
I"ll be very grateful :)

Regards
KZE
 
P

Per Jessen

Hi

This macro should do it:

Sub FillIn()
Dim cell As Range
For Each cell In Range("A1", Range("A1").End(xlDown))
If cell.Offset(0, 1).Value = "" Then
cell.Offset(0, 1) = cell.Value
End If
Next
End Sub

To open the VBA editor hit Alt+F11, goto Insert > Module. Paste the above
code into the the code sheet.

Regards,
Per
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top