copy cell if value equals to

jkessous

New Member
Joined
Aug 3, 2011
Messages
6
Hi,
i have an excel macro that does the following.
if the value in Column V = yes then it copies 2 cells from the same line to a different sheet.
what i want to add is the following:
if the value = yes then
if cell XXX (for exable B - from the same row) value = camera then it will copy the rows to sheet camera.
if it equals to =AC it will copy the cells to another sheet and so on.

this is what i have.

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = True
If Target.Column <> 22 Then Exit Sub
If Target.Value = "Yes" Or Target.Value = "yes" Then
    Cells(Target.Row, "E").Copy Destination:=Sheets("Cameras").Range("A" & Rows.Count).End(xlUp).Offset(1)
    Cells(Target.Row, "V").Copy Destination:=Sheets("Cameras").Range("B" & Rows.Count).End(xlUp).Offset(1)
'    End If
'    If Cells(Target.Rows, "D") = Access Then
'    Cells(Target.Row, "E").Copy Destination:=Sheets("ACS").Range("A" & Rows.Count).End(xlUp).Offset(1)
'    Cells(Target.Row, "P").Copy Destination:=Sheets("ACS").Range("B" & Rows.Count).End(xlUp).Offset(1)
'    End If
End If
If Target.Column <> 22 Then Exit Sub
If Target.Value = "No" Then
    Cells(Target.Row, "E").Copy Destination:=Sheets("Cameras").Range("D" & Rows.Count).End(xlUp).Offset(1)
    Cells(Target.Row, "V").Copy Destination:=Sheets("Cameras").Range("E" & Rows.Count).End(xlUp).Offset(1)
End If
End Sub

thanks
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi. Try like this

Code:
Cells(Target.Row, "E").Copy Destination:=Sheets(Cells(Target.Row, "B").Value).Range("A" & Rows.Count).End(xlUp).Offset(1)
 
Upvote 0
thanks but small question - where do i choose to which sheet to copy this row?

for example:
if colum B (from traget.row) = camera
copy cell C (from target.row) to sheet camera

if colum B (from traget.row) = acs
copy cell C (from target.row) to sheet acs

etc.

thanks'
 
Upvote 0
Thanks VoG but this is not the case.

what if i need it to copy it to a different sheet.

For example

if colum B (from traget.row) = camera
copy cell C (from target.row) to sheet status (or any other sheet).

thanks
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top