ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   IF function (copy cell) in a macro (https://www.excelbanter.com/excel-discussion-misc-queries/196544-if-function-copy-cell-macro.html)

Aline

IF function (copy cell) in a macro
 
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
--
Aline

Bob Phillips

IF function (copy cell) in a macro
 
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)

"Aline" wrote in message
...
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
--
Aline




Gary''s Student

IF function (copy cell) in a macro
 
Range("B:B").Copy Range("C:C")
will copy column B to column C
--
Gary''s Student - gsnu200796

Aline

IF function (copy cell) in a macro
 
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.


--
Aline


"Bob Phillips" wrote:

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)

"Aline" wrote in message
...
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
--
Aline





Bob Phillips

IF function (copy cell) in a macro
 
I don't understand that bit.

--
HTH

Bob

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

"Aline" wrote in message
...
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.


--
Aline


"Bob Phillips" wrote:

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)

"Aline" wrote in message
...
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
--
Aline








All times are GMT +1. The time now is 02:59 PM.

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