IF function (copy cell) in a macro

A

Aline

How do I change the code so it will copy the content of column B to column C?

A B C
Dog 2007-10-22
Cat 2008-02-02 2008-02-02
Cat 2008-02-11


Here are the codes:
Dim LastRow As Long
Dim wks As Worksheet

Set wks = ActiveSheet

With wks
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
..Range("K2:K" & LastRow).Formula _
= "= IF(A2=""Cat"", B2, "" "")"
End With
Thanks,
Aline
 
B

Bob Phillips

Dim LastRow As Long
Dim wks As Worksheet

Set wks = ActiveSheet

With wks
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("C2:C" & LastRow).Formula _
= "= IF(A2=""Cat"",B2,"" "")"
End With

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
A

Aline

Thanks, it should be:
".Range("C2:C" & LastRow).Formula _"

But I still not sure how do I rewrite the code so it automaticaly copy the
date on C3.
 
B

Bob Phillips

I don't understand that bit.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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