Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy/Paste how to avoid the copy of formula cells w/o calc values | Excel Discussion (Misc queries) | |||
copy a block of cells | Excel Discussion (Misc queries) | |||
How to use macros to copy a range of cells which can exclude some cells which I didn't want to be copied? | Excel Worksheet Functions | |||
How to copy block of cells and keep grouping? | Excel Discussion (Misc queries) | |||
Using Command Button to copy cells | Excel Discussion (Misc queries) |