Copy of Cells if
Sub test()
Dim r1 As Range
Dim r2 As Range
Dim L As Long
Worksheets("scheduled").Activate
nlastrow = ActiveSheet.UsedRange.Rows.Count
For L = 1 To nlastrow
If Worksheets("scheduled").Cells(L, 24).Value = "X" Then
Worksheets("scheduled").Activate
Set r1 = Worksheets("scheduled").Range(Cells(L, 1), Cells(L, 8))
Worksheets("test").Activate
Set r2 = Worksheets("test").Range(Cells(L, 1), Cells(L, 8))
r1.Copy r2
Else
End If
Next
End Sub
This version only copies specific rows.
--
Gary''s Student
"jkrist46" wrote:
I got help with this in the past. But I need more help. What I need to
do is only copy cells in columns A-H if column 24 has an X in it. This
is what I have so far. Thanks in advance for your help.
Joe
Sub test()
Dim r1 As Range
Dim r2 As Range
Dim L As Long
Worksheets("scheduled").Activate
For L = 1 To 65536
If Cells(L, 24).Value = "X" Then
Set r1 = Worksheets("scheduled").Range("A:H")
Set r2 = Worksheets("test").Range("A:H")
r1.copy r2
Exit Sub
Else
End If
Next
End Sub
--
jkrist46
|