Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Problem copying to another sheet with specific criteria

I am having problems with the code below. What I am trying to get it to do
is if the data in any of the cells of column I says €śFollow Up Immediately€ť,
€śFollow Up in 1 Day€ť, or €śFollow Up in 2 Days€ť then copy the data in cells
A:D of that row into the next blank row of another sheet called €śupcoming
follow-ups€ť.

There are two problems with the code in its current form. The first problem
is that it will only copy the data in column A. The second problem is that
when I run the macro I can see it performing the first IF statement correctly
(expect for only copying column A) however when it starts the second and then
the third IF statement it doesnt put them in the next empty row. Instead it
starts at row 2 and overwrites what the previous IF statement did.

Any suggestion on how to modify this code would be greatly appreciated.

--Bob


Sub guided_copy_to_followup()
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2
c = 2
d = 2

For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & c)
c = c + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & d)
d = d + 1
End If
Next a
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Problem copying to another sheet with specific criteria

....is this any better?
Rgds
J

Sub guided_copy_to_followup()
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2

For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
Next a
End Sub



On Oct 23, 5:53 am, Bob wrote:
I am having problems with the code below. What I am trying to get it to do
is if the data in any of the cells of column I says "Follow Up Immediately",
"Follow Up in 1 Day", or "Follow Up in 2 Days" then copy the data in cells
A:D of that row into the next blank row of another sheet called "upcoming
follow-ups".

There are two problems with the code in its current form. The first problem
is that it will only copy the data in column A. The second problem is that
when I run the macro I can see it performing the first IF statement correctly
(expect for only copying column A) however when it starts the second and then
the third IF statement it doesn't put them in the next empty row. Instead it
starts at row 2 and overwrites what the previous IF statement did.

Any suggestion on how to modify this code would be greatly appreciated.

--Bob

Sub guided_copy_to_followup()
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2
c = 2
d = 2

For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & c)
c = c + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & d)
d = d + 1
End If
Next a
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Problem copying to another sheet with specific criteria

Thank you. The code works perfectly.

I have one other issue I would appreciate any possible help with. I have
another workbook that I am trying to do a similar process with except copy
and paste noncontiguous cells in one sheet(€śmotivation€ť) to columns in
another sheet(€śfollowup€ť). The workbooks are set up very similar to each
other so I was assuming that the codes would be similar but I cant quite get
it to work.

If column I of Motivation says €śFollow Up Immediately€ť, €śFollow Up in 1
Day€ť, or €śFollow Up in 2 Days€ť then I am trying to copy cells A:D, F:H, J, U,
W of that row into columns A:J of the next blank row of the sheet Followup.

Any help in modifying the code for the previous workbook or if that isnt
possible creating new code for this task would be greatly appreciated.

--Bob


"WhytheQ" wrote:

....is this any better?
Rgds
J

Sub guided_copy_to_followup()
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2

For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
Next a
End Sub



On Oct 23, 5:53 am, Bob wrote:
I am having problems with the code below. What I am trying to get it to do
is if the data in any of the cells of column I says "Follow Up Immediately",
"Follow Up in 1 Day", or "Follow Up in 2 Days" then copy the data in cells
A:D of that row into the next blank row of another sheet called "upcoming
follow-ups".

There are two problems with the code in its current form. The first problem
is that it will only copy the data in column A. The second problem is that
when I run the macro I can see it performing the first IF statement correctly
(expect for only copying column A) however when it starts the second and then
the third IF statement it doesn't put them in the next empty row. Instead it
starts at row 2 and overwrites what the previous IF statement did.

Any suggestion on how to modify this code would be greatly appreciated.

--Bob

Sub guided_copy_to_followup()
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2
c = 2
d = 2

For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & c)
c = c + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & d)
d = d + 1
End If
Next a
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Problem copying to another sheet with specific criteria

I reckon it'll be almost the same. Maybe the following will work?!
Rgds
J


Sub guided_copy_to_followup()

lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2

For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a & ":D" & a, "F" & a & ":H" & a, "J" & a, "U" & a, "W"
& a).Copy Sheets("followup").Range("A" & b & ":J" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a & ":D" & a, "F" & a & ":H" & a, "J" & a, "U" & a, "W"
& a).Copy Sheets("followup").Range("A" & b & ":J" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a & ":D" & a, "F" & a & ":H" & a, "J" & a, "U" & a, "W"
& a).Copy Sheets("followup").Range("A" & b & ":J" & b)
b = b + 1
End If
Next a
End Sub


On Oct 25, 7:54 am, Bob wrote:
Thank you. The code works perfectly.

I have one other issue I would appreciate any possible help with. I have
another workbook that I am trying to do a similar process with except copy
and paste noncontiguous cells in one sheet("motivation") to columns in
another sheet("followup"). The workbooks are set up very similar to each
other so I was assuming that the codes would be similar but I can't quite get
it to work.

If column I of Motivation says "Follow Up Immediately", "Follow Up in 1
Day", or "Follow Up in 2 Days" then I am trying to copy cells A:D, F:H, J, U,
W of that row into columns A:J of the next blank row of the sheet Followup.

Any help in modifying the code for the previous workbook or if that isn't
possible creating new code for this task would be greatly appreciated.

--Bob



"WhytheQ" wrote:
....is this any better?
Rgds
J


Sub guided_copy_to_followup()
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2


For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
Next a
End Sub


On Oct 23, 5:53 am, Bob wrote:
I am having problems with the code below. What I am trying to get it to do
is if the data in any of the cells of column I says "Follow Up Immediately",
"Follow Up in 1 Day", or "Follow Up in 2 Days" then copy the data in cells
A:D of that row into the next blank row of another sheet called "upcoming
follow-ups".


There are two problems with the code in its current form. The first problem
is that it will only copy the data in column A. The second problem is that
when I run the macro I can see it performing the first IF statement correctly
(expect for only copying column A) however when it starts the second and then
the third IF statement it doesn't put them in the next empty row. Instead it
starts at row 2 and overwrites what the previous IF statement did.


Any suggestion on how to modify this code would be greatly appreciated.


--Bob


Sub guided_copy_to_followup()
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2
c = 2
d = 2


For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & c)
c = c + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & d)
d = d + 1
End If
Next a
End Sub- Hide quoted text -- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Problem copying to another sheet with specific criteria

J,

Thanks for the code unfortunately its not quite working correctly. When I
run it I get a €śCompile error: Wrong number of arguments or invalid property
assignment€ť message. I have tried to do some tweaking to it and believe that
part of the problem may be that the Ranges are too long. If I alter the
ranges to only contain two arguments as follows then it runs without the
error message.

Range("A" & a & ":D" & a, "F" & a).Copy Sheets("followup ").Range("A" & b &
":J" & b)

However, this obviously only copies columns A:F instead of producing the
original desired results of copying columns A, B, C, D, F, G, H, J, U, & W.
Additionally, column E is copied with the altered code which I cannot figure
out why because it is not included in the specified range.

Once again, any suggestions on how to fix the code would be greatly
appreciated.

Thanks,
--Bob


"WhytheQ" wrote:

I reckon it'll be almost the same. Maybe the following will work?!
Rgds
J


Sub guided_copy_to_followup()

lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2

For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a & ":D" & a, "F" & a & ":H" & a, "J" & a, "U" & a, "W"
& a).Copy Sheets("followup").Range("A" & b & ":J" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a & ":D" & a, "F" & a & ":H" & a, "J" & a, "U" & a, "W"
& a).Copy Sheets("followup").Range("A" & b & ":J" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a & ":D" & a, "F" & a & ":H" & a, "J" & a, "U" & a, "W"
& a).Copy Sheets("followup").Range("A" & b & ":J" & b)
b = b + 1
End If
Next a
End Sub


On Oct 25, 7:54 am, Bob wrote:
Thank you. The code works perfectly.

I have one other issue I would appreciate any possible help with. I have
another workbook that I am trying to do a similar process with except copy
and paste noncontiguous cells in one sheet("motivation") to columns in
another sheet("followup"). The workbooks are set up very similar to each
other so I was assuming that the codes would be similar but I can't quite get
it to work.

If column I of Motivation says "Follow Up Immediately", "Follow Up in 1
Day", or "Follow Up in 2 Days" then I am trying to copy cells A:D, F:H, J, U,
W of that row into columns A:J of the next blank row of the sheet Followup.

Any help in modifying the code for the previous workbook or if that isn't
possible creating new code for this task would be greatly appreciated.

--Bob



"WhytheQ" wrote:
....is this any better?
Rgds
J


Sub guided_copy_to_followup()
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2


For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a & ":D" & a).Copy Sheets("upcoming
follow-ups").Range("A" & b)
b = b + 1
End If
Next a
End Sub


On Oct 23, 5:53 am, Bob wrote:
I am having problems with the code below. What I am trying to get it to do
is if the data in any of the cells of column I says "Follow Up Immediately",
"Follow Up in 1 Day", or "Follow Up in 2 Days" then copy the data in cells
A:D of that row into the next blank row of another sheet called "upcoming
follow-ups".


There are two problems with the code in its current form. The first problem
is that it will only copy the data in column A. The second problem is that
when I run the macro I can see it performing the first IF statement correctly
(expect for only copying column A) however when it starts the second and then
the third IF statement it doesn't put them in the next empty row. Instead it
starts at row 2 and overwrites what the previous IF statement did.


Any suggestion on how to modify this code would be greatly appreciated.


--Bob


Sub guided_copy_to_followup()
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
b = 2
c = 2
d = 2


For a = 1 To lastrow
If Cells(a, 9) = "Follow Up Immediately" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & b)
b = b + 1
End If
If Cells(a, 9) = "Follow Up in 1 Day" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & c)
c = c + 1
End If
If Cells(a, 9) = "Follow Up in 2 Days" _
Then
Range("A" & a).Copy Sheets("upcoming follow-ups").Range("A" & d)
d = d + 1
End If
Next a
End Sub- Hide quoted text -- Show quoted text -



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
Copying rows with specific criteria Secret Squirrel Excel Discussion (Misc queries) 2 July 27th 08 08:22 AM
Copying Data from one sheet to another sheet on a specific day Gav123 Excel Worksheet Functions 0 May 1st 07 10:17 AM
Copying specific cells from a sheet to another Catalin Excel Discussion (Misc queries) 1 July 28th 06 11:59 PM
Copying Specific Values From Sheet Jenn Excel Discussion (Misc queries) 1 July 11th 05 09:22 PM
Copying specific rows from one sheet to another Chris Excel Programming 2 October 17th 03 11:40 PM


All times are GMT +1. The time now is 03:21 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"