ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to copy cell base on value in different cell (https://www.excelbanter.com/excel-programming/336152-how-copy-cell-base-value-different-cell.html)

CN

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



Tom Ogilvy

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





CN

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






Tom Ogilvy

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








CN

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










All times are GMT +1. The time now is 03:37 AM.

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