Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default 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






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a macro i can use to copy a cell +1 Bill M. Excel Discussion (Misc queries) 4 February 12th 08 02:59 PM
Macro copy function Nick Krill Excel Discussion (Misc queries) 1 April 4th 07 07:03 PM
copy name from active sheet to cell - using macro or function dymek Excel Worksheet Functions 2 October 2nd 06 12:32 PM
Using macro to copy a part of a cell content to next cell Charles Excel Discussion (Misc queries) 6 May 31st 06 05:57 AM
If than copy function / Macro Sweetetc Excel Worksheet Functions 2 April 7th 06 06:30 PM


All times are GMT +1. The time now is 01:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"