Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 7
Default Need help with copy if

What I am trying to do is copy column A-D from "scheduled" worksheet to "test" worksheet if column X has an "X" in the column. Is this possible and if so how is it done.

Last edited by jkrist46 : March 16th 06 at 12:28 PM
  #2   Report Post  
Posted to microsoft.public.excel.newusers
Gary''s Student
 
Posts: n/a
Default Need help with copy if

Enter and run this small macro:


Sub Macro1()
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:D")
Set r2 = Worksheets("test").Range("A:D")
r1.Copy r2
Exit Sub
Else
End If
Next

End Sub


-- Gary's Student


"jkrist46" wrote:


What I am trying to do is copy column A-D from "scheduled" worksheet to
"test" worksheet if column X has an "X" in the column. Is this
possible and if so how is it done.


--
jkrist46

  #3   Report Post  
Posted to microsoft.public.excel.newusers
David McRitchie
 
Posts: n/a
Default Need help with copy if

as written this macro would take 3 minutes to run on a slower system
(600kHz, 128M Ram). With minor revision it should run in well under a
second with a few hundred rows of data.

You should not be using a fixed number for number of rows in a worksheet,
and you should be at least limiting the range to the used range.
In other words you should not be testing rows beyond the data that you have.

Since you do the same thing, copy all of column A:D form "scheduled" to
"test" all you really need to check , according to your macro is if there is
an "X" (capitalized) in any cell in Column X., which could be done without
any loop, though I doubt this is what the poster really had in mind. (apparently
the specifications are ambiguous, because that would be one interpretation).
Since Don chose that criteria also maybe that is what was really meant. .

If only rows that had the "X" in them were to be copied, then a filter might be
used and then copy the filtered list to the second sheet.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Gary''s Student" wrote in message
...
Enter and run this small macro:


Sub Macro1()
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:D")
Set r2 = Worksheets("test").Range("A:D")
r1.Copy r2
Exit Sub
Else
End If
Next

End Sub


-- Gary's Student


"jkrist46" wrote:


What I am trying to do is copy column A-D from "scheduled" worksheet to
"test" worksheet if column X has an "X" in the column. Is this
possible and if so how is it done.


--
jkrist46



  #4   Report Post  
Posted to microsoft.public.excel.newusers
Don Guillett
 
Posts: n/a
Default Need help with copy if

try this where sheet2 is the source sheet and sheet5 is the destination.
Sub copyifx()
With Sheets("sheet2")
If Application.CountIf(.Columns("x"), "x") 0 Then _
..Columns("a:d").Copy Sheets("sheet5").Columns("a")
End With
End Sub

--
Don Guillett
SalesAid Software

"jkrist46" wrote in message
...

What I am trying to do is copy column A-D from "scheduled" worksheet to
"test" worksheet if column X has an "X" in the column. Is this
possible and if so how is it done.


--
jkrist46



  #5   Report Post  
Junior Member
 
Posts: 7
Default

Quote:
Originally Posted by jkrist46
What I am trying to do is copy column A-D from "scheduled" worksheet to "test" worksheet if column X has an "X" in the column. Is this possible and if so how is it done.

Thanks everyone


  #6   Report Post  
Posted to microsoft.public.excel.newusers
Don Guillett
 
Posts: n/a
Default Need help with copy if

You never did tell us what got you to the proper answer.

--
Don Guillett
SalesAid Software

"jkrist46" wrote in message
...

jkrist46 Wrote:
What I am trying to do is copy column A-D from "scheduled" worksheet to
"test" worksheet if column X has an "X" in the column. Is this
possible and if so how is it done.



Thanks everyone


--
jkrist46



  #7   Report Post  
Junior Member
 
Posts: 7
Default

Quote:
Originally Posted by jkrist46
What I am trying to do is copy column A-D from "scheduled" worksheet to "test" worksheet if column X has an "X" in the column. Is this possible and if so how is it done.

It worked in a round about way. I had to do some tweeking due to others changing columns.

Thanks
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 tabs(sheets) from workbook without link to original source Rich Ulichny Excel Discussion (Misc queries) 3 August 25th 05 02:11 AM
Copy shortcut BJH Excel Worksheet Functions 0 August 10th 05 12:41 AM
How can I copy cell formats in functions? Twitty Kitty Excel Worksheet Functions 3 July 24th 05 12:26 AM
Copy sheet 1 data to sheet 2 cells. Tom Doggett Excel Worksheet Functions 1 July 19th 05 11:49 PM
Copy without Hidden Cols - How abrogard Excel Discussion (Misc queries) 1 July 15th 05 07:54 AM


All times are GMT +1. The time now is 05:45 PM.

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"