LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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

 
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 11:11 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"