close

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(quot;scheduledquot;).Activate

For L = 1 To 65536
If Cells(L, 24).Value = quot;Xquot; Then
Set r1 = Worksheets(quot;scheduledquot;).Range(quot;A:Hquot;)
Set r2 = Worksheets(quot;testquot;).Range(quot;A:Hquot;)
r1.copy r2
Exit Sub
Else
End If
Next

End Sub
Sub test()
Dim r1 As Range
Dim r2 As Range
Dim L As Long

Worksheets(quot;scheduledquot;).Activate
nlastrow = ActiveSheet.UsedRange.Rows.Count

For L = 1 To nlastrow
If Worksheets(quot;scheduledquot;).Cells(L, 24).Value = quot;Xquot; Then
Worksheets(quot;scheduledquot;).Activate
Set r1 = Worksheets(quot;scheduledquot;).Range(Cells(L, 1), Cells(L, 8))
Worksheets(quot;testquot;).Activate
Set r2 = Worksheets(quot;testquot;).Range(Cells(L, 1), Cells(L, 8))
r1.Copy r2
Else
End If
Next
End Sub

This version only copies specific rows.
--
Gary''s Studentquot;jkrist46quot; wrote:

gt;
gt; I got help with this in the past. But I need more help. What I need to
gt; do is only copy cells in columns A-H if column 24 has an X in it. This
gt; is what I have so far. Thanks in advance for your help.
gt; Joe
gt;
gt; Sub test()
gt; Dim r1 As Range
gt; Dim r2 As Range
gt; Dim L As Long
gt;
gt; Worksheets(quot;scheduledquot;).Activate
gt;
gt; For L = 1 To 65536
gt; If Cells(L, 24).Value = quot;Xquot; Then
gt; Set r1 = Worksheets(quot;scheduledquot;).Range(quot;A:Hquot;)
gt; Set r2 = Worksheets(quot;testquot;).Range(quot;A:Hquot;)
gt; r1.copy r2
gt; Exit Sub
gt; Else
gt; End If
gt; Next
gt;
gt; End Sub
gt;
gt;
gt; --
gt; jkrist46
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()