help to copy range to another sheet when meet conditions

nhnn1986

Board Regular
Joined
Oct 12, 2017
Messages
92
Hi all

I want to have macro do that:
find each cell in sheet(3144).column(B) with value = "R-101" then
Copy range(Ei:Ni) to sheets(02).range(Cz:Lz)
Copy 8th characters from range (Ai) to sheets(02).range(Bz)

with: i = 2 to last row in sheet(3144)
and z = 10 to last row in sheets(02)
My code belove don't work, please help me

Code:
Sub Copy()Dim lrowa As Long, j As Long, z As Long


With Sheets("3144")
    lrowa = .Cells(Rows.Count, 1).End(xlUp).Row
        For j = 2 To lrowa
            For z = 10 To Sheets("02").Cells(Rows.Count, "C").End(xlUp).Row
                If .Cells(j, "B").Value = "R-101" Then
                .Range(.Cells(j, "E"), .Cells(j, "N")).Copy Sheets("02").Range("C" & z)
                Sheets("02").Range("B" & z).Value = Mid(.Range("A" & j), 8, 8)
                End If
            Next z
            
        Next j
       
End With
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,224,835
Messages
6,181,247
Members
453,026
Latest member
cknader

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