Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CN CN is offline
external usenet poster
 
Posts: 6
Default How to copy cell base on value in different cell

If I has column E = "a" & col F = "b" then copy cell in col A to col H in any
row have those value.
Thanks in advance,
CN


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to copy cell base on value in different cell

In H2 for example, put in a formula like

=if(and(E2="a",F2="b"),A2,"")

then drag fill down the column.

--
regards,
Tom Ogilvy

"CN" wrote in message
...
If I has column E = "a" & col F = "b" then copy cell in col A to col H in

any
row have those value.
Thanks in advance,
CN




  #3   Report Post  
Posted to microsoft.public.excel.programming
CN CN is offline
external usenet poster
 
Posts: 6
Default How to copy cell base on value in different cell

Hi Tom,
Thanks for reply this post,
In H2 example, that mean for Row 2 only or they can be any row?
Here some code I has put together, it work but not met all required I need,
please help:
Sub ButtonCopy()
Range("F2:F20").Select
Do Until ActiveCell = ""
If ActiveCell = "" Then End
ActiveCell.Select
If ActiveCell = "a" Then ' right here I sould add another condition (E)
in here
With Selection.Interior
..ColorIndex = 6
..Pattern = xlSolid
..PatternColorIndex = xlAutomatic
End With
End If
ActiveCell.Offset(1, 0).Activate
Loop
Range("B2:B20").Select 'Here, I do not want to copy
all in col B
Selection.Font.ColorIndex = 9
Selection.Copy

'Paste results
ActiveSheet.Paste
Range("H2:H20").Select 'Here, I do not want to paste
all in col H
ActiveSheet.Paste
Selection.Font.ColorIndex = 9

I am using range to copy and paste, but that not what I want, I just want to
copy only if col E = 'a' and F = 'b' on all the row relate to this.
Please help, thanks
CN


"Tom Ogilvy" wrote:

In H2 for example, put in a formula like

=if(and(E2="a",F2="b"),A2,"")

then drag fill down the column.

--
regards,
Tom Ogilvy

"CN" wrote in message
...
If I has column E = "a" & col F = "b" then copy cell in col A to col H in

any
row have those value.
Thanks in advance,
CN





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to copy cell base on value in different cell

Sub ButtonCopy()
Dim cell as Range, rw as Long
for each cell in Range("F2:F20")
if isempty(cell) then exit sub
rw = cell.row
if lcase(cell.Value) = "a" and _
lcase(cells(rw,"E").Value) = "b" then
cells(rw,"A").copy Destination:=cells(rw,"H")
end if
Next
End sub

--
Regards,
Tom Ogilvy



"CN" wrote in message
...
Hi Tom,
Thanks for reply this post,
In H2 example, that mean for Row 2 only or they can be any row?
Here some code I has put together, it work but not met all required I

need,
please help:
Sub ButtonCopy()
Range("F2:F20").Select
Do Until ActiveCell = ""
If ActiveCell = "" Then End
ActiveCell.Select
If ActiveCell = "a" Then ' right here I sould add another condition (E)
in here
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
ActiveCell.Offset(1, 0).Activate
Loop
Range("B2:B20").Select 'Here, I do not want to copy
all in col B
Selection.Font.ColorIndex = 9
Selection.Copy

'Paste results
ActiveSheet.Paste
Range("H2:H20").Select 'Here, I do not want to paste
all in col H
ActiveSheet.Paste
Selection.Font.ColorIndex = 9

I am using range to copy and paste, but that not what I want, I just want

to
copy only if col E = 'a' and F = 'b' on all the row relate to this.
Please help, thanks
CN


"Tom Ogilvy" wrote:

In H2 for example, put in a formula like

=if(and(E2="a",F2="b"),A2,"")

then drag fill down the column.

--
regards,
Tom Ogilvy

"CN" wrote in message
...
If I has column E = "a" & col F = "b" then copy cell in col A to col H

in
any
row have those value.
Thanks in advance,
CN







  #5   Report Post  
Posted to microsoft.public.excel.programming
CN CN is offline
external usenet poster
 
Posts: 6
Default How to copy cell base on value in different cell

Thanks, it work very good.
Very appreciated.
CN

"Tom Ogilvy" wrote:

Sub ButtonCopy()
Dim cell as Range, rw as Long
for each cell in Range("F2:F20")
if isempty(cell) then exit sub
rw = cell.row
if lcase(cell.Value) = "a" and _
lcase(cells(rw,"E").Value) = "b" then
cells(rw,"A").copy Destination:=cells(rw,"H")
end if
Next
End sub

--
Regards,
Tom Ogilvy



"CN" wrote in message
...
Hi Tom,
Thanks for reply this post,
In H2 example, that mean for Row 2 only or they can be any row?
Here some code I has put together, it work but not met all required I

need,
please help:
Sub ButtonCopy()
Range("F2:F20").Select
Do Until ActiveCell = ""
If ActiveCell = "" Then End
ActiveCell.Select
If ActiveCell = "a" Then ' right here I sould add another condition (E)
in here
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
ActiveCell.Offset(1, 0).Activate
Loop
Range("B2:B20").Select 'Here, I do not want to copy
all in col B
Selection.Font.ColorIndex = 9
Selection.Copy

'Paste results
ActiveSheet.Paste
Range("H2:H20").Select 'Here, I do not want to paste
all in col H
ActiveSheet.Paste
Selection.Font.ColorIndex = 9

I am using range to copy and paste, but that not what I want, I just want

to
copy only if col E = 'a' and F = 'b' on all the row relate to this.
Please help, thanks
CN


"Tom Ogilvy" wrote:

In H2 for example, put in a formula like

=if(and(E2="a",F2="b"),A2,"")

then drag fill down the column.

--
regards,
Tom Ogilvy

"CN" wrote in message
...
If I has column E = "a" & col F = "b" then copy cell in col A to col H

in
any
row have those value.
Thanks in advance,
CN








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
emptying the contets of a cell base on the value of another cell tracktor Excel Worksheet Functions 3 May 17th 08 06:27 AM
Define a cell value base on the date BaseballFan Excel Discussion (Misc queries) 2 April 10th 07 01:51 AM
Hiding row base on cell content brownti via OfficeKB.com Excel Discussion (Misc queries) 11 February 14th 07 06:53 PM
unique values in a cell base on another cell Jay Excel Discussion (Misc queries) 2 November 18th 05 06:46 PM
change tab color base on cell value G. Wolfe Excel Programming 3 December 6th 04 08:21 PM


All times are GMT +1. The time now is 05:06 AM.

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

About Us

"It's about Microsoft Excel"