LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem copying rows to new worksheet

Hi all,

I am trying to copy an entire row to a new worksheet based on th
contents of a cell in that row.
If the cell in col 19 equals "Yes" then the row is copied to the ne
sheet (sheet1) and then deleted from the original sheet (Shut Plan)
The code I have got does this function well, but my problem is that i
I re-run the macro, then the new rows being copied accross overwrit
the old ones. I need to be able to select the next blank row on the ne
sheet (sheet1).
The background to this is that once a job on the 'Shut Plan' i
marked as 'Yes' then the job is done and the row can now be archived o
'sheet1' by running a macro. This macro also deletes the row off th
'Shut Plan' as it is now archived on 'sheet1'.
The code I have got so far (which I found on this forum !) is :

Dim iCt As Integer
Dim iRow1 As Integer
Dim iRow2 As Integer
Dim ws1 As Worksheet
Dim ws2 As Worksheet

Set ws1 = Sheets("Shut Plan")
Set ws2 = Sheets("Sheet1")
iRow1 = 2
iRow2 = 2
'copy from sheet1 to sheet2
Do Until ws1.Cells(iRow1, 18) = "--1"
If ws1.Cells(iRow1, 19) = "Yes" Then
For iCt = 1 To 21
ws2.Cells(iRow2, iCt) = ws1.Cells(iRow1, iCt)
Next iCt
iRow2 = iRow2 + 1
End If
iRow1 = iRow1 + 1
Loop

'delete from sheet1
For iCt = iRow1 To 2 Step -1
If ws1.Cells(iCt, 19) = "Yes" Then ws1.Rows(iCt).Delete
Next iCt

Any help with this will be much appreciated,
Many thanks
Trefo

--
Message posted from http://www.ExcelForum.com

 
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 of data into new worksheet but placing data into colu Thalarctos Excel Discussion (Misc queries) 0 June 6th 10 04:01 AM
Copying rows from 2 sheets to a new worksheet based on date criter Phill_Morgan Excel Discussion (Misc queries) 9 August 29th 07 08:03 AM
Copying data from one worksheet to another from rows to columns ked Excel Worksheet Functions 0 January 11th 07 06:21 PM
Copying worksheet problem owl37 Excel Discussion (Misc queries) 0 January 10th 06 10:09 AM
Problem copying worksheet containing code module Basie[_2_] Excel Programming 1 September 3rd 03 12:28 AM


All times are GMT +1. The time now is 12:53 PM.

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

About Us

"It's about Microsoft Excel"