Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 7
Default Copy of Cells if

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   Report Post  
Posted to microsoft.public.excel.newusers
Gary''s Student
 
Posts: n/a
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
copy a block of cells florin Excel Discussion (Misc queries) 2 October 12th 05 03:16 PM
How to use macros to copy a range of cells which can exclude some cells which I didn't want to be copied? excelnovice Excel Worksheet Functions 2 September 25th 05 12:38 AM
How to copy block of cells and keep grouping? dstock Excel Discussion (Misc queries) 2 July 6th 05 08:42 PM
Using Command Button to copy cells Pennington Excel Discussion (Misc queries) 1 April 29th 05 02:30 AM


All times are GMT +1. The time now is 06:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"